0
Good afternoon devs... I am studying spring mvc, in my system I have a controler that has a mapped method as @getmappint(/search/{id}), as below:
@GetMapping("buscar/{id}")
public ModelAndView alterarPrestador(@PathVariable ("id") String id, ModelMap model) {
PrestadorModel user = new PrestadorDao().getPrestador(id);
model.addAttribute("PrestadorModel", user);
//model.addAttribute("atualizar", true);
ModelAndView visao = new ModelAndView("alterar", model);
return visao;
}
it returns a modelndview, which is the JSP page change. until ai blz, it fills the form fields with the correct information. this and the form:
<body>
<h4>Alterar dados de prestaddor</h4>
<form:form modelAttribute="PrestadorModel" action="update"
method="post">
<div>
<div>
<form:hidden path="id" />
</div>
<div>
<form:label path="pisPasep">PIS/PASEP:</form:label>
<form:input path="pisPasep" />
</div>
<div>
<form:label path="nome">Nome completo:</form:label>
<form:input path="nome" />
</div>
<input type="submit" value="Atualizar">
</div>
</form:form>
when sending the data by this form, to the update() method, it says that the POST method is not supported, this is the method that receives the data from the change.jsp
@PostMapping("update")
public ModelAndView atualizar(@ModelAttribute("PrestadorModel") PrestadorModel prestador, ModelMap model){
PrestadorDao dao = new PrestadorDao();
dao.atualizarPrestador(prestador);
//model.addAttribute("msg", "Dados atualizados com sucesso!!");
return new ModelAndView("listaprestador");
}
I expect the help of you.