首页 文章

整数的Thymeleaf开关案例

提问于
浏览
4

我一直在寻找有关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的事实 . 我通过简单地打印它上面的段落中的值进行检查,但打印的消息总是'No goal specified' .

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

1 回答

  • 5

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

相关问题