小编Roe*_*erg的帖子

整数的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>
    <p th:case="3">Overall fit</p>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我知道一个事实${profileModel.goal}是1,2或3.我通过简单地打印它上面的段落中的值进行检查,但打印的消息总是"没有指定目标".

是不是可以切换整数,或者我很快会有一个facepalm时刻?

java integer switch-statement thymeleaf

4
推荐指数
1
解决办法
739
查看次数

标签 统计

integer ×1

java ×1

switch-statement ×1

thymeleaf ×1