c forEach 遍歷集合中的元素屬性詳解,判斷是否是最後一個元素,
阿新 • • 發佈:2018-11-21
分享一下我老師大神的人工智慧教程吧。零基礎,通俗易懂!風趣幽默!http://www.captainbed.net/
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
c:forEach 遍歷集合中的元素,判斷是否是最後一個元素
<c:forEach items="${pointSection}" var="chl" varStatus="stat"><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條資料。