
Thymeleaf具有
<c:choose>与Thymeleaf 2.0中引入的and
<c:when>:
th:switch和
th:case属性等效的功能。
它们按照您的期望工作,使用
*默认情况:
<div th:switch="${user.role}"> <p th:case="'admin'">User is an administrator</p> <p th:case="#{roles.manager}">User is a manager</p> <p th:case="*">User is some other thing</p> </div>见这个语法简单的解释(或Thymeleaf教程)。
免责声明 :根据StackOverflow规则的要求,我是Thymeleaf的作者。