关于thymeleaf的属性设置
th:attr自定义多属性设置
thymeleaf可用通过th:attr设置自定义的属性,以便在前端应用到对应的属性值:
<a href="#" th:attr="data-url=@{/manage/index},data-title=#{name}"></a>
th:if多条件判断
th:if多条件判断,li标签里的th:if都满足是才会显示该标签
<div th:object="${session.user}">
<ul th:if="${#object.islogin}">
<li th:if="${#object.type==1}" th:if="${#object.name=='admin'}">admin管理员</li>
<li th:if="${#object.type==2}" th:if="${#object.name=='user'}">admin管理员</li>
</ul>
</div>
th:class表达式选择class
通过表达式判断选择应用对应的class
<a href="#" th:class="${user.type==1}? 'user' : 'admin'" th:text="${user.name}"></a>
1
以上内容是本人在开发过程中需要用的内容,网上并没有相关的介绍使用。
---------------------
作者:流远长季
来源:优快云
原文:https://blog.youkuaiyun.com/cndnsnnn/article/details/78759445?utm_source=copy
版权声明:本文为博主原创文章,转载请附上博文链接!