整数的Thymeleaf开关案例

时间:2016-02-26 16:16:07

标签: 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>
    <p th:case="3">Overall fit</p>
</div>

现在我知道${profileModel.goal}是1,2或3的事实。我只是在上面的段落中打印了值,但是打印的消息总是“没有指定目标”。

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

1 个答案:

答案 0 :(得分:5)

您的默认情况应该在结尾,而不是开头。