简体   繁体   中英

How can I use multiple conditions (and, or) in thymeleaf th:if

When I use thymeleaf th:if , I want to sum this code:

th:if=${lang.equals('A') or lang.equals('B')}.

I use || , the "or", but it is not used.

It works in spring framework, thymeleaf:

th:if=${lang.equals('A')
th:if=${lang.equals('B')

I want to sum this code.

th:if=${lang.equals('A') or lang.equals('B')}

You can combine them

th:if="${lang == 'A' OR lang == 'B'}"

Try this one (PS- Please ensure that you're putting the double-inverted commas carefully in starting and ending )

th:if="${lang=='A'} and ${lang=='B'}"

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