Thymeleaf 整数开关盒
Thymeleaf switch case on integer
我一直在寻找有关 Thymeleaf 的 'new' 开关盒的文档,但要么我找错了地方,要么找不到太多。
无论如何,这是我的问题:
<div th:switch="${profileModel.goal}">
<p th:case="*">No goal specified</p>
<p th:case="1">Lose weight</p>
<p th:case="2">Gain muscle</p>
<p th:case="3">Overall fit</p>
</div>
现在我知道了一个事实 ${profileModel.goal}
是 1、2 或 3。我通过简单地打印它上面一段中的值来检查,但打印的消息总是 'No goal specified'。
是不是不能切换整数,还是我马上就要捂脸了?
您的默认大小写应该在结尾,而不是开头。
我一直在寻找有关 Thymeleaf 的 'new' 开关盒的文档,但要么我找错了地方,要么找不到太多。 无论如何,这是我的问题:
<div th:switch="${profileModel.goal}">
<p th:case="*">No goal specified</p>
<p th:case="1">Lose weight</p>
<p th:case="2">Gain muscle</p>
<p th:case="3">Overall fit</p>
</div>
现在我知道了一个事实 ${profileModel.goal}
是 1、2 或 3。我通过简单地打印它上面一段中的值来检查,但打印的消息总是 'No goal specified'。
是不是不能切换整数,还是我马上就要捂脸了?
您的默认大小写应该在结尾,而不是开头。