我想检查 Employee.dateOfTermination 中的日期是否在日期“现在”之后。不幸的是,运行以下代码后,我没有得到任何数据:
<td> <div th:switch="${employee.dateOfTermination}">
<span th:case="'< now'">CASE 1</span>
<span th:case="'> now'" th:text="${#dates.format(employee.dateOfTermination, 'dd-MM-yyyy')}">CASE 2</span></div></td>
Run Code Online (Sandbox Code Playgroud)
问题来了,thymeleaf 的语法对我来说确实显得不适用而且恶心。我尝试使用 th:if 并解析 int 。
我会这样做:
<span th:if="${employee.dateOfTermination.before(#dates.createNow())}">Case 1</span>
<span th:if="${employee.dateOfTermination.after(#dates.createNow())}">Case 2</span>
Run Code Online (Sandbox Code Playgroud)
或者,如果您确实喜欢这个开关:
<div th:switch="${employee.dateOfTermination.before(#dates.createNow())}">
<span th:case="true">Case 1</span>
<span th:case="false">Case 2</span>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8369 次 |
| 最近记录: |