2014-10-03 17 views
2

我想在這樣的Thymeleaf模板上設置一些條件。 但它不起作用。如何在Thymeleaf上設置多個條件

<li th:if="${entry.description != null && entry.owner == true}" th:each="entry : ${entryList}" class="group">

如何使這個代碼正常工作?

回答

9

更換

"${entry.description != null && entry.owner == true}" 

"${entry.description != null and entry.owner == true}" 

僅供參考,你可以看看這個線程: http://forum.thymeleaf.org/How-to-have-multiple-condition-in-an-th-if-tag-td4025931.html

讓我知道你如何去

+1

Aeseir, 謝謝對於回答我的問題。 我可以通過你的答案解決問題。 你的快速回答確實幫了我。 謝謝。 – 2014-10-03 07:18:51

+0

歡迎您:) – Aeseir 2014-10-04 06:36:38

+0

@ryokato:您可以通過使用[別名]的[eq','lt','gt'等等(http://www.thymeleaf.org/doc/) articles/standarddialect5minutes.html)進行比較,* eg *:'「$ {entry.description ne null and entry.owner eq true}」'。就個人而言,如果明文表示也可用,我不喜歡使用原始操作符(儘管我認爲這是一個有趣的問題)。 – 2016-06-18 01:39:35