评估列表是否为空JSTL

时间:2009-09-23 01:54:18

标签: 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}">  

如何判断ArrayList是否为空?

2 个答案:

答案 0 :(得分:238)

empty是一名运营商。

<c:if test="${empty myObject.featuresList}">

答案 1 :(得分:65)

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

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

here's标记文档。