en Lopes
en Lopes

Reputation: 2153

Conditionals in Thymeleaf

I have this piece of code in my Thymeleaf template

<INPUT TYPE="text" TH:VALUE="${searchForm.male}" />
<span th:if="${searchForm.male == 'true' }">
   IS TRUE
</span>
<span th:unless="${searchForm.male == 'true'}">
   IS NOT TRUE
</span>

but this is what I see :

enter image description here

Upvotes: 0

Views: 430

Answers (1)

If the male property is boolean just remove the quotes as follows

<input type="text" th:value="${searchForm.male}"/>
<span th:if="${searchForm.male == true }">IS TRUE</span>
<span th:unless="${searchForm.male == true}">IS NOT TRUE</span>

Upvotes: 2

Related Questions