Java 检查Thymeleaf中是否有其他内容

Java 检查Thymeleaf中是否有其他内容,java,html,spring,jakarta-ee,thymeleaf,Java,Html,Spring,Jakarta Ee,Thymeleaf,我不熟悉thymeleaf,希望将以下Jsp代码转换为thymeleaf。我不知道如何使用thymeleaf处理if-else。我的jsp页面看起来类似于: index.jsp 你好,客人 输入${variable} 有人能帮我把它转换成thymeleaf格式吗? <div th:switch="${user.role}"> <p th:case="'admin'">User is an administrator</p> <p th:c

我不熟悉thymeleaf,希望将以下Jsp代码转换为thymeleaf。我不知道如何使用thymeleaf处理if-else。我的jsp页面看起来类似于:

index.jsp


你好,客人


输入${variable}

有人能帮我把它转换成thymeleaf格式吗?


<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文档


用户是管理员

用户是经理

取自Thymeleaf文档

<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>