<div th:if="${tblUserList != null}">
--content--
</div>
上面的 thymeleaf 代码不起作用,其中 tblUserList 是一个列表。所以我想检查列表是否为空而不是检查它的空值。怎么做?
原文由 Rahul Raj 发布,翻译遵循 CC BY-SA 4.0 许可协议
<div th:if="${tblUserList != null}">
--content--
</div>
上面的 thymeleaf 代码不起作用,其中 tblUserList 是一个列表。所以我想检查列表是否为空而不是检查它的空值。怎么做?
原文由 Rahul Raj 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用 Thymeleaf 3.xx ,您可以更优雅地验证列表:
<div th:if="${tblUserList!=null and !tblUserList.empty}"></div>
要么
<div th:if="${tblUserList!=null and !tblUserList.isEmpty()}"></div>
原文由 Alexey Nikitenko 发布,翻译遵循 CC BY-SA 4.0 许可协议
2 回答1.5k 阅读✓ 已解决
2 回答902 阅读✓ 已解决
1 回答1.1k 阅读✓ 已解决
1 回答913 阅读✓ 已解决
2 回答791 阅读
1 回答786 阅读✓ 已解决
2 回答1.1k 阅读
您可以执行以下操作: