簡體   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