Evaluate if list is empty JSTL

后端 未结 2 611
攒了一身酷
攒了一身酷 2020-12-07 12:13

I\'ve been trying to evaluate if this array list is empty or not but none of these have even compiled:



        
相关标签:
2条回答
  • 2020-12-07 12:40

    empty is an operator:

    The empty operator is a prefix operation that can be used to determine whether a value is null or empty.

    <c:if test="${empty myObject.featuresList}">
    
    0 讨论(0)
  • 2020-12-07 12:41

    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.

    0 讨论(0)
提交回复
热议问题