<s:iterator value="projectDetails" var="pd" status="count"> <s:if test="#count.odd||#cout.first"> <tr> </s:if> <td width="30%" class="form_label"><s:property value="projectAttrName" />:</td> <td width="20%" class="form_content"> <input type="hidden" name="projectAttrValues[<s:property value='sort'/>].projectAttrId" value="<s:property value="projectAttrId"/>" /> <input type="text" class="field_adapt_70" name="projectAttrValues[<s:property value='sort'/>].value" value="<s:property value="projectAttrValue"/>" > </td> <!--偶数情况--> <s:if test="#count.even&&#count.last"> </tr> </s:if> <!--奇数情况--> <s:if test="#count.odd&&#count.last"> <td width="30%" class="form_label"></td> <td width="20%" class="form_content" style="height: 10px;"></td> </tr> </s:if> </s:iterator>
iterator标签有如下方法:
boolean isEven() 当前迭代元素索引是否为偶数;
boolean isOdd() 当前迭代元素索引是否为奇数;
boolean isLast() 是否为最后一条元素;
boolean isFirst() 是否为第一条元素。