Jeff
Jeff

Reputation: 8421

Java Thymeleaf: Could not parse expression

I have faced with the error:

Could not parse as expression: "${consultation.getStatus().toString()}!=SCHEDULED && consultation.getStatus().toString()}!=RECEIVED"

In the line :

<span th:if="${consultation.getStatus().toString()}!=SCHEDULED &amp;&amp; consultation.getStatus().toString()}!=RECEIVED" th:text="${consultation.getStatus()}"></span>

i cannot figure out why Thymeleaf is complaining?

Update: I am trying to check an attribute if it is equal to SCHEDULED or RECEIVED

Upvotes: 1

Views: 605

Answers (2)

notionquest
notionquest

Reputation: 39186

Try this

${consultation.getStatus().toString() ne 'SCHEDULED'; and consultation.getStatus().toString() ne 'RECEIVED'}

Upvotes: 1

Krzysztof Atłasik
Krzysztof Atłasik

Reputation: 22595

${...} means that you want to evaluate expression. You should only have one expression in yout th:if tag. Also logical and is not && but just word and.

Change it as below and it should start working:

${consultation.getStatus().toString()!='SCHEDULED' and consultation.getStatus().toString()!='RECEIVED'}

Upvotes: 0

Related Questions