FE/html

[Error] org.thymeleaf.exceptions.TemplateInputException

잔망루피 2022. 7. 22. 22:15
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를 이용해 댓글이 있을 때 댓글의 사이즈를 구하도록 한다.

반응형