<c:forEach /c:forEach>中varStatus的作用

varStatus封装了当前遍历的状态,可以从该对象上查看是遍历到了第几个元素
举例如下
            <c:forEach items="${cs}" var="c" varStatus="st">
                <c:if test="${st.count>=5 and st.count<=8}">
                        <span>
                            <a href="forecategory?cid=${c.id}">
                                    ${c.name}
                            </a>
                            <c:if test="${st.count!=8}">
                                <span>|</span>
                            </c:if>
                        </span>
                </c:if>
            </c:forEach>
${st.count>=5 and st.count<=8}即判断在第5个到第8个元素间打印出对应的名字。

猜你喜欢

转载自www.cnblogs.com/xcl666/p/11966198.html