Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.
<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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away