Java Thymeleaf开关外壳在整数上
我一直在寻找有关Thymeleaf“新”开关盒的文档,但要么我找错了地方,要么没有太多。 无论如何,这是我的问题:Java Thymeleaf开关外壳在整数上,java,integer,switch-statement,thymeleaf,Java,Integer,Switch Statement,Thymeleaf,我一直在寻找有关Thymeleaf“新”开关盒的文档,但要么我找错了地方,要么没有太多。 无论如何,这是我的问题: <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>
<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。我只是通过在上面的一段中打印值进行检查,但打印的消息总是“未指定目标”
是否无法切换整数,或者我很快就会有一个facepalm时刻?您的默认情况应该在末尾,而不是开头。您看到了什么问题?您是否遇到错误,或者它始终与第一个案例匹配?还是什么都没做?你有没有试过用双引号括起来的char 1,比如“'1'”我有Ankit,结果是一样的!掌纹