ERROR 16980 --- [nio-8080-exec-9] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-9] Exception processing template "post/detail": An error happened during template parsing (template: "class path resource [templates/post/detail.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/detail.html]")
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "#lists.size(commentList)" (template: "post/detail" - line 249, col 23)
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "#lists.size(commentList)" (template: "post/detail" - line 249, col 23)
Caused by: java.lang.IllegalArgumentException: Cannot get list size of null
2022-07-18 11:27:21.642 ERROR 16980 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/detail.html]")] with root cause
java.lang.IllegalArgumentException: Cannot get list size of null
댓글이 0개 일때 생기는 에러
<div class="card-header bi bi-chat-dots">
<span th:if=${commentList} th:text="${#lists.size(commentList)}"></span>
Comments
</div>
th:if를 이용해 댓글이 있을 때 댓글의 사이즈를 구하도록 한다.
반응형
'FE > html' 카테고리의 다른 글
Uncaught TypeError: $(...).summernote is not a function (0) | 2022.08.03 |
---|---|
첨부 파일 UI (0) | 2022.07.31 |
[Thymeleaf] 게시글 상세보기에서 댓글 개수 출력 (0) | 2022.07.07 |
[JS] 댓글 작성/수정/삭제 후 비동기 방식으로 출력 (0) | 2022.07.06 |
수정 버튼 클릭시 알림창을 띄우고 요청 보내기 (0) | 2022.06.09 |