背景
JUNITでControlelerのテストをしている際、以下の事象に遭遇した。
エラーログ
Request processing failed: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "${isWorking} != null && ${jobChangeCount} != null" (template: "entryHistory/entry_history_apply_detail_pc" - line 265, col 37)
jakarta.servlet.ServletException: Request processing failed: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "${isWorking} != null && ${jobChangeCount} != null" (template: "entryHistory/entry_history_apply_detail_pc" - line 265, col 37)
at app//org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)
要は、Thymeleafの書き方がいけなかったっぽい。。
エラーが発生した箇所
<th:block th:if="${isWorking} != null && ${jobChangeCount} != null">
調査
論理演算子(and, or, not)を使うときに、&&とか||とか!を使ったらエラーになる。
使うなら、そのまま、and, or, notと記載する。
参考資料
修正後
<th:block th:if="${isWorking} != null and ${jobChangeCount} != null">
これでOK!