struts 2 的s标签没有for循环 不过counter是个很好用的东东:
<s:if test="%{curr_page<=5}"> <s:if test="%{count_page<=8}"> <s:bean name="org.apache.struts2.util.Counter" id="counter1"> <s:param name="first" value="1" /> <s:param name="last" value="count_page" /> <s:iterator> <s:if test="%{curr_page==(current-1)}"> <a href="<%=path%>/manuals/${ post_slug}-${media_id }&page=<s:property />" class="active"> <span ><s:property /></span></a> </s:if> <s:else> <a href="<%=path%>/manuals/${ post_slug}-${media_id }&page=<s:property />"> <span><s:property /></span></a> </s:else> </s:iterator> </s:bean> </s:if> <s:elseif test="%{count_page>8}"> <s:bean name="org.apache.struts2.util.Counter" id="counter2"> <s:param name="first" value="1" /> <s:param name="last" value="8" /> <s:iterator> <s:if test="%{curr_page==(current-1)}"> <a href="<%=path%>/manuals/${ post_slug}-${media_id }&page=<s:property />" class="active"> <span ><s:property /></span></a> </s:if> <s:else> <a href="<%=path%>/manuals/${ post_slug}-${media_id }&page=<s:property />"> <span><s:property /></span></a> </s:else> </s:iterator> </s:bean> <a href="<%=path%>/manuals/${ post_slug}-${media_id }&page=${count_page}"> <span>${count_page}</span></a> </s:elseif> </s:if>
这是我写分页用到的循环和条件变换的一段代码,相当于以后携带吗的一个参考,也可以是一个大家写struts 2 for循环的一个参考