Witam wszystkich,
otóż mam problem z przekazaniem parametru w petli a dokładnie do edycji i usuwania.
Dodam iż próbowałem na kilka sposobów. Linki wpisane z palca w URL działają poprawnie.
W Usuń
i Edytuj
wyskakuje There was an unexpected error (type=Not Found, status=404). No message available. `` HTML "allNotes"
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Notes List</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Notes List</h1>
<table>
<tr>
<th>ID</th>
<th>TITLE</th>
<th>CONTENT</th>
<th>CREATED</th>
<th>MODIEFIED</th>
</tr>
<tr th:each="note : ${notes}">
<td th:text="${note.id}">ID</td>
<td th:text="${note.title}">TITLE</td>
<td th:text="${note.content}">CONTENT</td>
<td th:text="${note.created}">CREATED</td>
<td th:text="${note.modiefied}">CREATED</td>
<td><a href="@{/edit/} + ${id}"}>Usuń<</a></td>
<td><a href="@{|/edit/${note.id}|}" >Edytuj</a></td>
<td><a href="@{|http://localhost:8080/edit/${note.id}|}" >Edytuj2</a></td>
</tr>
</table>
<p>
<a href="http://localhost:8080/saveNote">Add Note</a>
<a href="http://localhost:8080/">Main Page</a></p>
</body>
</html>
Kontroler:
@PostMapping("/edit/{id}")
public String editNote2(@PathVariable Long id, Note note) {
noteService.update(note);
return "redirect:/";
}
@RequestMapping("/allNotes")
public String allNotes(Model model) {
model.addAttribute("notes", noteService.notes());
return "allNotes";
}
@GetMapping("/delete/{id}")
@ResponseBody
public String deleteNote(@PathVariable Integer id, Note note){
noteService.delete(id);
return "Notatke usunieto o id "+id;
}