Struts2 循环编辑指定次数
引用
<s:bean name= "org.apache.struts2.util.Counter" id= "counter" >
<s:param name="first" value= "0" />
<s:param name="last" value= "10" />
<s:iterator>
counter:<s:property value="current-1" />
</s:iterator>
</s:bean>
其中first属性指定循环起始值,last指定循环终止值,其它相关属性可以查看org.apache.struts2.util.Counter类源码。
在下面迭代器中输入循环的当前值,即:current-1
实际例子
引用
<table class="table">
<tbody>
<tr>
<th>烟叶类型</th>
<th>品种</th>
<th>等级</th>
<th>产地</th>
<th>年度</th>
<th>规格</th>
<th width="40px">标件标志</th>
<th>发运件数</th>
<th>验收件数</th>
<th>差额件数</th>
<th>总重量(KG)</th>
<th>抽包件数</th>
<th width="70px">备注</th>
</tr>
<!-- 循环判断数量 一般7行 -->
<s:bean name="org.apache.struts2.util.Counter" id="counter">
<s:param name="first" value="0" />
<s:param name="last" value="6" />
<s:iterator>
<s:iterator value="%{billData.billDtl}" id='vo' status='st'>
<s:if test="#st.count eq #counter.current">
<tr>
<td>${vo.invName}</td>
<td>${vo.tcBreedName}</td>
<td>${vo.tcGradeName}</td>
<td>${vo.tcLocName}</td>
<td>${vo.tcYear}</td>
<td>${tobacSpecMap[vo.specCd]}</td>
<td>${specFlagMap[vo.specFlg]}</td>
<td>${vo.sendQty}</td>
<td>${vo.realQty}</td>
<td>${vo.realQty - vo.sendQty}</td>
<td>${vo.realWgt}</td>
<td>${vo.checkQty}</td>
<s:if test="#st.count == 1">
<td rowspan="8">${billData.billEntity.remark}</td>
</s:if>
</tr>
</s:if>
</s:iterator>
<s:if test="%{current > billData.billDtl.size}">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<s:if test="current == 1">
<td rowspan="8" > </td>
</s:if>
</tr>
</s:if>
</s:iterator>
</s:bean>
<tr>
<td colspan="7" style="text-align: left;"><label>合计:<label></td>
<td>${billData.billContent['totalSendQty']}</td>
<td>${billData.billContent['totalRealQty']}</td>
<td>${billData.billContent['totalIntQty']}</td>
<td>${billData.billContent['totalWgt']}</td>
<td>${billData.billContent['totalCheckQty']}</td>
</tr>
</tbody>
</table>
明天你还会爱我?