Thymeleaf判断集合是否为空
最近项目使用的是thymeleaf。项目架构是Springboot+Thymeleaf。

在判断集合是否为空的时候踩了坑与大家分享。

 Thymeleaf判断集合是否为空

 

 

以下代码是判断集合是否为空的,myCart是集合。

<div th:if="${#lists.isEmpty(myCart)}" ></div>
反之判断集合不是空的判断

<div th:if="${not #lists.isEmpty(myCart)}"></div>
或者

<div th:if="not ${#lists.isEmpty(myCart)}"></div>

需要提醒的是 th:if做判断之后是不可以在后面直接写循环的不然即便th:if为false th:each还是会执行的。
原文地址:http://www.dandelioncloud.cn/article/details/609045327238970

相关文章:

  • 2022-02-24
  • 2022-12-23
  • 2021-12-04
  • 2021-11-27
  • 2021-11-28
  • 2021-11-28
  • 2021-07-04
  • 2021-06-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-09-22
  • 2021-11-17
相关资源
相似解决方案