Thymeleaf有两个变量的条件

如果我的应用程序中的creditUser的信用额少于特定菜品的费用,我目前正在尝试隐藏特定元素。 (这是一种点菜系统,仅用于培训目的)而且我不知道如何设置百里香叶的状况,使其正常工作……

我尝试了各种解决方案,但是我在互联网上可以找到的都是这样:th:if =“ * {得分 = 0}”

我当前的版本如下:

<td ><a th:if="${creditUser.credit} &gt; ${dish.small}" class="btn btn-success" th:href="@{/order/orderDish/(creditUserId=${creditUser.id},dishId=${dish.dishId},delId=${dish.delId},dishName=${dish.name},price=${dish.small})}" th:text="${dish.small}">Bestellen</a></td>

现在我没有收到任何错误消息,但是该元素也没有显示。关于如何将百里香中的一个值与另一个值进行比较的任何建议? (creditUser被传递,它只是没有显示在代码部分中,并且该解决方案适用于诸如creditUser.credit> 1之类的固定值)

timeyy 回答:Thymeleaf有两个变量的条件

所有内容都应放在相同的花括号内: th:if="${creditUser.credit > dish.small}"

本文链接:https://www.f2er.com/3165739.html

大家都在问