jstl 循环获取集合的下标
<c:forEach var="teacherExpInfo" items="${teacherExpRankList}" varStatus="status">
<tr>
<td class="text-center">
<c:choose> //遍历teacherExpRankList 集合的小标
</c:when>
<c:when test="${status.index== 1}">
<img src="${pageContext.request.contextPath}/static/images/ico/ranking-no2.png" alt="2">
</c:when>
<c:when test="${status.index == 2}">
<img src="${pageContext.request.contextPath}/static/images/ico/ranking-no3.png" alt="3">
</c:when>
<c:otherwise >
${status.index+1}
</c:otherwise>
</c:choose>
</td>
<td>
<div class="clearfix">
<img class="tl-user-img pull-left" src="${teacherExpInfo.image}" height="60" width="60" alt="">
<h4>
${teacherExpInfo.name}<br>
<small>${teacherExpInfo.school}</small>
</h4>
</div>
</td>
<td class="text-center">${teacherExpInfo.totalExp}</td>
</tr>
</c:forEach> 阅读更多
<tr>
<td class="text-center">
<c:choose> //遍历teacherExpRankList 集合的小标
<c:when test="${status.index == 0}"> // index:当前这次迭代从0开始的迭代索引。
<img src="${pageContext.request.contextPath}/static/images/ico/ranking-no1.png" alt="1"> //位于集合的前三名给予相应的等级标识</c:when>
<c:when test="${status.index== 1}">
<img src="${pageContext.request.contextPath}/static/images/ico/ranking-no2.png" alt="2">
</c:when>
<c:when test="${status.index == 2}">
<img src="${pageContext.request.contextPath}/static/images/ico/ranking-no3.png" alt="3">
</c:when>
<c:otherwise >
${status.index+1}
</c:otherwise>
</c:choose>
</td>
<td>
<div class="clearfix">
<img class="tl-user-img pull-left" src="${teacherExpInfo.image}" height="60" width="60" alt="">
<h4>
${teacherExpInfo.name}<br>
<small>${teacherExpInfo.school}</small>
</h4>
</div>
</td>
<td class="text-center">${teacherExpInfo.totalExp}</td>
</tr>
</c:forEach> 阅读更多
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: <c:forEach>用法详解
- 下一篇: foreach中获取当前索引值