public String deleteStudentBook(@RequestParam Long roll_no, Long book_id, Model model) {
log.debug("Received request to delete student book. roll_no: {}, book_id: {}", roll_no, book_id);
StudentDetailsDto studentDetails = studentDetailsService.getStudentById(roll_no)
.orElseThrow(() -> {
log.error("Student not found for roll_no: {}", roll_no);
return new StudentNotFound("No Student Found");
});
if (studentDetails.getBooksDetails().size() == 1) {
log.debug("Deleting student books and details. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(book_id);
studentDetailsService.deleteStudentDetails(roll_no);
return "redirect:/home";
} else {
log.debug("Deleting student books. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(book_id);
return "redirect:/allbooks";
}
}```
#Getting 404 Error while Loading the thymleaf page
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @icy field! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Student Books</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body class="bg-gray-100 p-6">
<div class="container mx-auto">
<div class="w-full h-auto flex justify-center items-center">
<h1 class="text-xl font-bold text-gray-800 mb-4 whitespace-nowrap sm:text-xl md:text-2xl lg:text-3xl">
<span th:text="${studentAllBooks.name}"></span>
</h1>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6 sm:mt-6 md:mt-8 lg:mt-10">
<div th:each="book : ${studentAllBooks.booksDetails}" class="relative bg-white shadow-md rounded-lg p-4">
<!-- Dustbin Icon -->
<form th:action="@{/deletestudentbook}" method="post" style="display:inline;">
<input type="hidden" name="roll_no" th:value="${studentAllBooks.roll_no}" />
<input type="hidden" name="book_id" th:value="${book.bookId}" />
<button type="submit" class="absolute top-2 right-2 text-gray-500 hover:text-red-500">
<i class="fas fa-trash-alt"></i>
</button>
</form>
```
I dont know why whats the issue is ? Can Anyone Help
Even the loggers arenot loggging anything when goes to the /deletestudentbook endpoint
ohh
inspect element -> network tab then click on submit button
that will show whats happening
I am getting this
..
i dont know where this allbooks some from ?
My html page name is allbooks
Wdym ?
@tired bane
I am returning the page if the student is deleted but it's not getting it instead got got this allbooks error with 404
if (studentDetails.getBooksDetails().size() == 1) {
log.debug("Deleting student books and details. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(book_id);
studentDetailsService.deleteStudentDetails(roll_no);
return "redirect:/home";
} else {
log.debug("Deleting student books. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(book_id);
return "redirect:/allbooks";
}
i dont see a 404 in your network logs
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
Yehh I have it
And I am returning it after deleting a single book from the student book list but it gives error