Question

When using Thymeleaf, I am trying to show a certain image conditionally. This works properly

<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 changing the &gt to &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 receive an error that states "missing expected character '&'"

All I did was change the &gt to &ge..

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

I have done the check with ge first and there is no difference. I have also tried as the doc shows without the ampersand as such

*{score} ge; 0" 

and it still fails and throws errors. According to my pom.xml file I am using ThymeLeaf 2.1.2.RELEASE.

Thanks,

Was it helpful?

Solution

Thanks to Jim on the Thymeleaf Forum.. There is no xml Entity for >= or <=. This fixed it.

<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=""/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top