简体   繁体   English

如何在 thymeleaf th:if 中使用多个条件(和,或)

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

When I use thymeleaf th:if , I want to sum this code:当我使用 thymeleaf th:if ,我想总结这段代码:

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

I use ||我用|| , the "or", but it is not used. ,“或”,但未使用。

It works in spring framework, thymeleaf:它适用于 spring 框架,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 )试试这个(PS-请确保您在开始和结束时小心地放置双引号)

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

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

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