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

xiaoxiao2021-02-28  127

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条数据。
转载请注明原文地址: https://www.6miu.com/read-63514.html

最新回复(0)