Timeleaf Conditional Statement

When using Thymeleaf, I am trying to show a specific image conditionally. It works fine

<img th:if="*{ score &lt; 20 and score &gt; 0}" src="images/Fast-Track-No1.jpg" th:href="@{/images/Fast-Track-No1.jpg}"  style = "width: 450px;" alt=""/>

However, this does not work. Only change & gt> ge

<img th:if="*{ score &lt; 20 and score &ge; 0}" src="images/Fast-Track-No1.jpg" th:href="@{/images/Fast-Track-No1.jpg}"  style = "width: 450px;" alt=""/>

I get the error "Missing expected character '&'"

All I did was change & gt> ge ..

I followed the documentation here: http://www.thymeleaf.org/doc/html/Using-Thymeleaf.html#comparators-and-equality

At first I checked with ge, and there is no difference. I also tried, as the document shows no ampersand per se

*{score} ge; 0" 

and he still fails and causes errors. According to my pom.xml file, I am using ThymeLeaf 2.1.2.RELEASE.

Thanks,

+4
source share
1 answer

Thanks to Jim at the Timeleaf Forum. No xml Entity for> = or <=. This is fixed.

<img th:if="*{ score &lt; 20 and score &gt;= 0}" src="images/Fast-Track-No1.jpg" th:href="@{/images/Fast-Track-No1.jpg}"  style = "width: 450px;" alt=""/>
+3
source

Source: https://habr.com/ru/post/1528173/


All Articles