JSP常用的el表达式:判断是否为空、循环、比较、索引

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/monica1_1/article/details/81011713

java交流群:681223095

关注公众号,更多学习内容给予推送,争取每日更新

                                                                                                          

1、判断是否为空

如果为空

 <c:if test="${empty  allContactStatsPerMonth}">
     <ul class="def_report_td">
       <div style="text-align: center;">
             暂无数据
        </div>
      </ul>
 </c:if>

如果不为空

<c:if test="${not empty  allContactStatsPerMonth}">
不为空,展示数据
</c:if>

2、循环用<c:forEach></c:forEach>、当前list的索引${p.index}(注意:p是事先声明的。varstatus=“p”)

<c:forEach items="${allContactStatsPerMonth}" var="contactStatsPerMonth" varStatus="p">
     <c:if test="${p.index <= 50}">
           <ul class="def_report_td contact_area_analysis">
              <li style="width: 7%;">${contactStatsPerMonth.month}</li>  
            </ul>
      </c:if>
 </c:forEach>

猜你喜欢

转载自blog.csdn.net/monica1_1/article/details/81011713