I am conducting a CRUD project, with JAVA, Spring boot, Thymeleaf and JPA technologies. What happens

Asked

Viewed 21 times

-1

I am conducting a CRUD project, with JAVA, Spring boot, Thymeleaf and JPA technologies. What happens here is that I am trying to get information from the bank to perform an update/edition on people who already have registration in the system. The problem is in the code th:field="*{id}", whenever I run the error gives in the line in which it is, if I take it, the code works, however so that I can rescue information from the bank to perform the editing, I need it. It follows in attaching images of the personal classControl and gives HTML page where I rewrite the information in addition to the error code provided when I try to perform user editing on the system. In that, I wonder what I can do to fix it.

[![ package with.projectCrud.projectCrud01.control;

import java.util.List;

import org.springframework.Beans.factory.Annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.validation.Bindingresult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.Annotation.Getmapping; import org.springframework.web.bind.Annotation.Pathvariable; import org.springframework.web.bind.Annotation.Requestmapping; import org.springframework.web.bind.Annotation.Requestmethod; import org.springframework.web.servlet.Modelandview; import org.springframework.web.servlet.mvc.support.Redirectattributes;

import com.projectCrud.projectCrud01.model.Person; import with.projectCrud.projectCrud01.services.Personal services;

@Controller public class Personal Control {

@Autowired
PessoaServices pessoaServices;

@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView inicial() {
    ModelAndView modelAndView = new ModelAndView("inicio");
    return modelAndView;
}

@RequestMapping(value = "/pessoas", method = RequestMethod.GET)
public ModelAndView getPessoas() {
    ModelAndView modelAndView = new ModelAndView("paginaPessoas");
    List<Pessoa> pessoas = pessoaServices.findAll();
    modelAndView.addObject("paginaPessoas", pessoas);
    return modelAndView;
}

@RequestMapping(value = "/salvarpessoa", method = RequestMethod.GET)
public ModelAndView paginaCadastro() {
    ModelAndView modelAndView = new ModelAndView("pessoasCadastro");
    return modelAndView;
}

@RequestMapping(value = "/salvarpessoa", method = RequestMethod.POST)
public String salvarPessoa(@Validated Pessoa pessoa, BindingResult result, RedirectAttributes attributes) {
    /*if (result.hasErrors()) {
        return "redirect:/salvarpessoa";
    } */
    pessoaServices.save(pessoa);
    return "redirect:/pessoas";
}


@GetMapping("/editarpessoa/{idpessoa}")
public ModelAndView editar(@PathVariable("idpessoa") int idpessoa) {
    Pessoa pessoa = pessoaServices.findById(idpessoa);
    ModelAndView modelAndView = new ModelAndView("/pessoasCadastro");
    modelAndView.addObject("pessoaobj", pessoa.getId());
    return modelAndView;
}

} ]1]1


Salvar
Cancelar

Erro apresentado

  • Welcome to [en.so]! You have posted an image of the code and/or error message. Although it sounds like a good idea, it’s not! One of the reasons is that if someone wants to answer the question, they can’t copy the code and change something inside. Click on the [Edit] link and put the code/error as text. See more about this in these links - Manual on how NOT to ask questions, Post Error Message as Picture

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.