<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>
本文介绍了一个使用JSP和EL表达式来动态展示教师经验排名的网页实现方式。该页面通过遍历teacherExpRankList集合来显示每位教师的经验排名、头像、姓名、所在学校及总经验等信息,并为排名前三的教师提供了特别图标标识。

182

被折叠的 条评论
为什么被折叠?



