How do I set up multiple conditions on Thymeleaf

18,816

Replace

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

with

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

For reference you can check out this thread: http://forum.thymeleaf.org/How-to-have-multiple-condition-in-an-th-if-tag-td4025931.html

Let me know how you go

Share:
18,816

Related videos on Youtube

ryo kato
Author by

ryo kato

Updated on August 20, 2022

Comments

  • ryo kato
    ryo kato over 1 year

    I want to set up some conditions on Thymeleaf templates like this, but it doesn't work.

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

    How do I make this code correctly work?

  • ryo kato
    ryo kato over 9 years
    Aeseir, thank you for answering my question. I could solve the problem by your answer. your quick answer really helped me. thank you.
  • Priidu Neemre
    Priidu Neemre almost 8 years
    @ryokato: You could improve this even further by using the eq, lt, gt etc. class of aliases for comparisons, e.g.: "${entry.description ne null and entry.owner eq true}". Personally, I don't like using the raw operators if the plain-text representations are also available (although I guess that's a matter of taste).