我是thymeleaf的新手,想将以下Jsp代码转换为Thymeleaf。我不知道如何处理如果使用thymeleaf。我的jsp页面看起来类似于:
<div id="header">
<% if(${variable1}==null){%>
<a href="/home">Enter Here</a>
<br><a href="/signUp">Signup Here</a>
<% }else if(${variable}=="Guest"){%>
<p>Hello Guest</p>
<br><a href="play">Play game</a>
<% } else { %>
<p> Enter ${variable}</p>
<a href="play">Play game</a>
</div>
任何人都可以帮我转换为百万美元格式吗?
答案 0 :(得分:1)
<div th:switch="${user.role}">
<p th:case="'admin'">User is an administrator</p>
<p th:case="#{roles.manager}">User is a manager</p>
</div>
取自Thymeleaf文档 http://www.thymeleaf.org/doc/html/Using-Thymeleaf.html#simple-conditionals-if-and-unless