Witam wszystkich,
a więc mam problem z edycją w CRUD w Springu. Robiłem identycznie w jsp a teraz robie to samo w thymeleafie, choć nie wiem czy w tym problem.
@RequestMapping("/editNote/{id}")
public String editNote(@PathVariable Integer id, Model model) {
Note note=noteService.findById(id);
model.addAttribute("note",note);
noteService.update(note);
return "editNote";
}
@PostMapping("/editNote") // w ten sposob odbieram edytowana clienta z widoku edit.jsp
public String editNote2(@ Valid Note note) {
noteService.update(note);
return "redirect:/";
}
a tak wygląda mój widok :
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="pl">
<title>Good Thymes Virtual Grocery</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Welcome in Note</h1>
</p>
<form action="#" th:action="@{/editNote/{id}}" th:object="${note}" method="post">
<table border="1">
<tr>
<td><label th:text="#{msg.editTitle}" /></td>
<td><input type="text" th:field="*{title}" /></td>
</tr>
<tr>
<td><label th:text="#{msg.editContent}" /></td>
<td><input type="text" th:field="*{content}" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
wyskakuje mi następujący błąd :
2019-05-30 14:03:47.197 WARN 18219 --- [nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "{id}"]