JSTL判断server端返回的数据集合是否大于-0

  1. 直接用c标签:
    //引入标签库
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <c:if test="${empty items}">
       无数据 = items为null或者items.size<=0
    </c:if>
    
    <c:if test="${not empty items}">
        有数据 = items存在&&items.size>0
    </c:if>
     
  2. c标签和fn标签结合
    //引入标签库
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
    
    
    <c:if test="${ (empty requestScope.dataList) || (fn:length( requestScope.dataList ) <= 0) }">
    无数据 = items为null或者items.size<=0
    </c:if>
    
    <c:if test="${ (!empty requestScope.dataList) && (fn:length( requestScope.dataList ) > 0) }">
    有数据 = items存在&&items.size>0
    </c:if>
    
     

猜你喜欢

转载自hebad90.iteye.com/blog/2045840