LoginSignup
27

More than 5 years have passed since last update.

Thymeleafのif文で使う比較演算子の使い方

Last updated at Posted at 2015-01-30
<div data-th-if="${a > b}">
  true!
</div>

とかやると怒られます。

正しくは、

<div data-th-if="${a gt b}">
  true!
</div>

ようは、ThymeleafはHTMLなので『>』とか『<』とかそのまま書いちゃダメでしょってことです。
ちなみに『==』とかはHTMLでエスケープする必要がないので使うことができます。

よく分かる対応表

Javaの演算子 Thymeleafの演算子
> gt
< lt
>= ge
<= le
! not
== eq
!= neq
&& and
|| or

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
27