Boolean condition with Thymeleaf and Spring

后端 未结 2 1792
暗喜
暗喜 2021-02-13 20:33

I\'d like to add an error flag in my web page. How can I to check if a Spring Model attribute is true or false with Thymeleaf?

2条回答
  •  悲哀的现实
    2021-02-13 21:21

    The boolean literals are true and false.

    Using the th:if you will end up with a code like:

    or if you decide to go with the th:unless

    There is also a #bools utility class that you can use. Please refer to the user guide: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#booleans

提交回复
热议问题