简体   繁体   English

评估列表是否为空 JSTL

[英]Evaluate if list is empty JSTL

I've been trying to evaluate if this array list is empty or not but none of these have even compiled:我一直在尝试评估这个数组列表是否为空,但这些都没有编译:

<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}">  

How can I evaluate if an ArrayList is empty?如何评估 ArrayList 是否为空?

empty is an operator : empty是一个运算符

The empty operator is a prefix operation that can be used to determine whether a value is null or empty. empty操作符是一个前缀操作,可用于确定一个值是空还是空。

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

There's also the function tags, a bit more flexible:还有功能标签,更灵活一点:

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

And here's the tag documentation.这里的标签文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM