评估列表是否为空JSTL

Osc*_*Ryz 120 java jsp jstl

我一直在尝试评估这个数组列表是否为空,但这些数据列表都没有编译:

<c:if test="${myObject.featuresList.size == 0 }">                   
<c:if test="${myObject.featuresList.length == 0 }">                 
<c:if test="${myObject.featuresList.size() == 0 }">                 
<c:if test="${myObject.featuresList.length() == 0 }">                   
<c:if test="${myObject.featuresList.empty}">                    
<c:if test="${myObject.featuresList.empty()}">                  
<c:if test="${myObject.featuresList.isEmpty}">  
Run Code Online (Sandbox Code Playgroud)

如何评估ArrayList是否为空?

bob*_*nce 243

是一个操作员.

<c:if test="${empty myObject.featuresList}">
Run Code Online (Sandbox Code Playgroud)

  • 虽然记录了空操作符在v2.0之前的JSTL中的Set实现集合中不能很好地运行 (2认同)

Ste*_* B. 67

还有功能标签,更灵活一点:

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:if test="${fn:length(list) > 0}">
Run Code Online (Sandbox Code Playgroud)

这里的标签文档.