【发布时间】:2018-07-03 11:01:34
【问题描述】:
对 ThymeLeaf 非常陌生,但在我正在进行的项目中遇到了问题。在日志中得到以下错误:
Exception evaluating SpringEL expression: "!searchResults.results.empty"
看看有问题的代码是:
<th:block th:if="${!searchResults.results.empty}">
我认为感叹号 (!) 的位置不正确。我试过了:
<th:block th:if="${not searchResults.results.empty}">
但同样的错误评估。有人可以帮助我如何否定支票吗?
【问题讨论】:
-
你可以使用
th:unless -
另一个选项是“searchResults.results.empty == false”和@Alexander 的 th:unless。但我认为发生错误是因为无法评估“searchResults.results.empty”。属性是否为空,getter isEmpty() 或 getEmpty() 是否存在?
-
是的@Flocke,就是这样。进一步进入日志
Property or field 'empty' cannot be found on null。 Sumit 的空检查修复了它!
标签: javascript thymeleaf