1、th:if比较字符串

判断是不是为空:null:

<span th:if="${name} != null">不为空</span>
<span th:if="${name1} == null">为空</span>

判断是不是为空字符串: “”

<span th:if="${#strings.isEmpty(name1)}">空的</span>

判断是否相同:

<span th:if="${name} eq 'jack'">相同于jack,</span>
<span th:if="${name} eq 'ywj'">相同于ywj,</span>
<span th:if="${name} ne 'jack'">不相同于jack,</span>

是否包含(分大小写):

<span th:if="${#strings.contains(name,'ez')}">包ez</span>
<span th:if="${#strings.contains(name,'y')}">包j</span>

是否包含(不分大小写)

<span th:if="${#strings.containsIgnoreCase(name,'y')}">包j</span>

参考:
https://blog.csdn.net/qq_41765712/article/details/103285898

2、用switch-case 实现 if-else:

<td th:switch = "${ user.createTime != null }" >
    <div th:case="true" th:text = "${#dates.format( user.createTime , 'yyyy-MM-dd' )}" ></div>
    <div th:case="false" th:text = "‘---’" ></div>
</td>

参考:https://blog.csdn.net/beguile/article/details/86748011

3、th:onclick

th:onclick传参,需要使用[[]]将参数包括起来

参考:
https://blog.csdn.net/qq_40059532/article/details/104143937

posted on 2022-05-10 18:46  西伯尔  阅读(190)  评论(0编辑  收藏  举报