Thymeleaf: Not Equal Expression In Th:if
Very new to ThymeLeaf, but have encountered a problem on a project I am working on. Getting the following error in the logs: Exception evaluating SpringEL expression: '!searchResu
Solution 1:
Assuming from the code you've pasted, you want to implement a check where Thymeleaf checks for empty value in an Object. For that :---
<divth:if= "${searchResults.results != null}">
OR
<divth:if= "${searchResults.results != ''}">
Also, Alternatively What you can do is-- check on your Controller itself whether the object is empty or doesn't have any Value and send the response on your html page and then check as per that response on Thymeleaf, Like this :- - -
1.) Your controller :--
List ls = //some data from you DAO
if(ls.isEmpty()){
model.addAttribute("response", "NoData");
}else{
model.addAttribute("response", ls);
}
Then on your Thymeleaf :- - -
<th:block th:if="${response=='NoData'}"> No Data Found </th:block>
Post a Comment for "Thymeleaf: Not Equal Expression In Th:if"