使用strtuts2的iterator标签循环输出二维数组和嵌套集合
如果我们再加上一些判断条件,比如这个table的第一行是行头,第一列是列头,行头和列头正常显示,
而表格中数据则需要加上超链接,则将其中的
<s:property value="data4"/>这句修改为
Code
<s:if test="!(#st3.first)&&!(#st4.first)">
??? <a href="<s:url action="starInfo" namespace="/query/star">
??????? <s:param name="id"><s:property value="id"/></s:param>
??????? <s:param name="starType"><s:property value="starType[#st4.index-1]"/></s:param>
??????? </s:url>">
?????? <s:property value="data4"/>
??? </a>
</s:if>
<s:else>
??? <s:property value="data4"/>
</s:else>
其中
<s:if test="!(#st3.first)&&!(#st4.first)">
这句话里的#st3.first这种用法是返回当前被迭代元素是否是第一个元素
而
<s:property value="starType[#st4.index-1]"/>这句话是特意用来举例说明#st4.index这种用法的,
index返回的当前被迭代元素的索引,String[] starType;是传递到页面上的一个数组