简体   繁体   中英

Thymeleaf conditional with two variables

I am currently trying to hide specific elements, if the creditUser in my app has credit less than the costs of a specific dish. (It's kind of a dish ordering system, just for training purposes) And I cannot figure out how to set up the thymeleaf condition, to make it work...

I've tried all kinds of solutions, but all I can find on the internet is something like this: th:if="*{ score < 20 and score >= 0}"

my current version looks like this:

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

Now I don't get any error messages, but the element is also not showing up. Any suggestions on how to compare a value in thymeleaf to another value? (The creditUser is passed it is just not shown in the code part and the solution works with fixed values like creditUser.credit > 1)

Everything should be inside the same braces: th:if="${creditUser.credit > dish.small}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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