thymeleaf的判斷表達式如下所示:
themeleaf | 符號 | 備註 |
gt | > | great than(大於) |
ge | >= | great equal(大於等於) |
eq | == | equal(等於) |
lt | < | less than(小於) |
le | <= | less equal(小於等於) |
ne | != | not equal(不等於) |
例子:
<!--判斷成績-->
<td th:if="${test.Score} gt 0 and ${test.Score} lt 60">差</td>
<td th:if="${test.Score} ge 60 and ${test.Score} le 70">中</td>
<td th:if="${test.Score} gt 70 and ${test.Score} le 80">良</td>
<td th:if="${test.Score} gt 80 and ${test.Score} le 90">優</td>
<td th:if="${test.Score} gt 90 and ${test.Score} le 100">超級優秀</td>