1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Thymeleaf 】論理演算子を使用する際の注意点

Posted at

背景

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!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?