<div class="book_bottom-section">
<div class="formation-item d-flex" style="padding-top:5px;">
<form th:action="@{|/review/create/${book.id}|}" method="post">
<textarea name="content" id="content" rows="15"></textarea>
<input type="submit" value="리뷰등록">
</form>
<div>
<ul>
<li th:if="${not #lists.isEmpty(book.reviewList)}" th:each="review : ${book.reviewList}" th:text="${review.content}"></li>
<li th:if="${#lists.isEmpty(book.reviewList)}">리뷰가 없습니다.</li>
</ul>
</div>
<a th:href="@{|/review/delete/${book.id}|}"
class="delete btn btn-sm btn-outline-secondary"
th:text="삭제">
</a>
</div>
</div>
코드를 입력하세요
@GetMapping("/detail/{id}") //책에 대한 상세페이지
public String bookDetail(Model model, @PathVariable("id") Integer id) {
Book book = this.bookService.getBookById(id);
model.addAttribute("book", book);
return "book/book_detail";
}
코드를 입력하세요
@PreAuthorize("isAuthenticated()")
@PostMapping("/create/{id}")
public String reviewCreate(@PathVariable("id") Integer id, @Valid ReviewForm reviewForm,
BindingResult bindingResult, Principal principal, org.springframework.ui.Model model){
Book books = this.bookService.getBookById(id);
if (books == null) {
// 책이 존재하지 않는 경우에 대한 처리
return "redirect:/books/list"; // 예시로 책 목록 페이지로 리다이렉트
}
if (bindingResult.hasErrors()) {
model.addAttribute("books",books);
return "book_detail";
}
Member author = this.memberService.findByUsername(principal.getName());
if (author == null) {
// 작성자를 찾을 수 없는 경우에 대한 처리
return "redirect:/book/list"; // 예시로 홈 페이지로 리다이렉트
}
this.reviewService.create(books,reviewForm.getContent(), author);
return String.format("redirect:/book/detail/%d", id);
}```
코드를 입력하세요
"Exception evaluating SpringEL expression: 'review.content'"
https://github.com/BteamEcommers/EatBook/commit/e22ce62722ff4819b5442faca8b21868eab81d13