c forEach 遍历集合中的元素属性详解,判断是否是最后一个元素,

分享一下我老师大神的人工智能教程吧。零基础,通俗易懂!风趣幽默!http://www.captainbed.net/

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

c:forEach 遍历集合中的元素,判断是否是最后一个元素 

<c:forEach items="${pointSection}" var="chl" varStatus="stat">
        <c:if test="${!stat.last}" >
         <div class="item" id="_MYJD_repair" style="border-bottom-style: dotted;border-bottom-width: 1px;border-bottom-color: olive">
          <a href="pointProductController.html?flag=flagPProductsection${chl.pointseId}" class="zltda">${chl.section}</a>
         </div>
       </c:if>
        <c:if test="${stat.last}">
         <div class="item" id="_MYJD_repair">
          <a href="pointProductController.html?flag=flagPProductsection${chl.pointseId}" class="zltda">${chl.section}</a>
         </div>
        </c:if>

        </c:forEach>



<c:forEach varStatus="status">中 varStatus的属性简介

我们常会用c标签来遍历需要的数据,为了方便使用,varStatus属性可以方便我们实现一些与行数相关的功能,如:奇数行、偶数行差异;最后一行特殊处理等等。先就varStatus属性常用参数总结下:

${status.index}      输出行号,从0开始。
${status.count}      输出行号,从1开始。
${status.current}   当前这次迭代的(集合中的)项
${status.first}  判断当前项是否为集合中的第一项,返回值为true或false
${status.last}   判断当前项是否为集合中的最后一项,返回值为true或false
begin、end、step分别表示:起始序号,结束序号,跳跃步伐。

如:<c:forEach begin='1' end='5' step='2' items='${list}' var='item'>
表示:操作list集合汇中1~5条数据,不是逐条循环,而是按每2个取值。即操作集合中的第1、3、5条数据。

           

扫描二维码关注公众号,回复: 4176363 查看本文章

给我老师的人工智能教程打call!http://www.captainbed.net/

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_43741569/article/details/84305888