繁体   English   中英

Thymeleaf 有两个变量的条件

[英]Thymeleaf conditional with two variables

如果我的应用程序中的 creditUser 的信用低于特定菜肴的成本,我目前正在尝试隐藏特定元素。 (这是一种点菜系统,仅用于培训目的)而且我不知道如何设置 thymeleaf 条件,使其工作......

我尝试了各种解决方案,但我在互联网上只能找到这样的东西:th:if="*{ score < 20 and score >= 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>

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

一切都应该在同一个大括号内: th:if="${creditUser.credit > dish.small}"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM