I want to write a conditional expression using a trinomial operator in thymeleaf.

Asked 2 years ago, Updated 2 years ago, 136 views

I would like to write a conditional expression using the thymeleaf trinomial operator.

1, In the case of prod.Num=='12', indicate 'preparing'.
2, If prod.Num=='13'&prod.sis=='spring', I would like to say 'output' but
Please let me know how to write the conditional expression.

<div th:text="${prod.Num=='12'? 'Preparing':${prod.Num=='13'&prod.sis=='spring'}? 'Output':'123'}">/div>

thymeleaf

2022-09-30 21:43

1 Answers

It may be wrong because I haven't checked the operation, but I think this is probably the case.

<div th:text="${prod.Num=='12'}? 'Preparing':${prod.Num=='13'&prod.sis=='spring'}? 'Output':'123'">>/div>

However, nested trinomial operators are not recommended because they are less readable.

editing:

You need and instead of &, and then ().

<div th:text="${prod.Num=='12'}? 'Preparing': (${prod.Num=='13' and prod.sis=='spring'}? 'Output':'123')">/div>


2022-09-30 21:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.