0
Good colleagues, I am studying Spring through some video lessons and now I have the following problem that I cannot solve I have done everything in my power. The problem is this when I want to click on the link that would supposedly direct me to a page that would allow the change of a record sends the following error in the browser to mention that when I put the path in the url the page opens, the more when I call is that the error is triggered. What should I do?:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Sep 02 17:14:13 CAT 2019
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template [tarefas/alterar/1], template might not exist or might not be accessible by any of the configured Template Resolvers
below is the view element that calls the edit page:
<div class="card-footer bg-light">
<p>
<a th:href="@{/tarefas/alterar/{id}(id=${tarefa.id})}">Alterar</a>
</p>
</div>
below is controller action for the change:
@GetMapping("/alterar/{id}")
public ModelAndView alterar(@PathVariable Long id) {
ModelAndView mv = new ModelAndView();
Tarefa tarefa = rt.getOne(id);
mv.addObject("tarefa", tarefa);
return mv;
}
@PostMapping("/alterar")
public ModelAndView alterar(@Valid Tarefa tarefa, BindingResult result) {
ModelAndView mv = new ModelAndView();
if (tarefa.getDataExpiracao() == null) {
result.rejectValue("dataExpiracao", "tarefa.dataExpiracaoInvalida", "A data de expiração obrigatória.");
} else {
if (tarefa.getDataExpiracao().before(new Date())) {
result.rejectValue("dataExpiracao", "tarefa.dataExpiracaoInvalida",
"A data de expiração não pode ser anterior à data actual.");
}
}
if (result.hasErrors()) {
mv.setViewName("tarefas/alterar");
mv.addObject(tarefa);
} else {
mv.setViewName("redirect:/tarefas/listar");
rt.save(tarefa);
}
return mv;
}