Struts中用<bean:size>和<bean:write>来显示查询结果集合之总记录数,并使用Struts的logic标签,遍历List时使用indeId来自动输出序号并加一.
例子如下:
例子如下:
<logic:present name="targetbean">
<bean:size id="sizeOfThis" scope='request' name="targetbean" />
<p align="center">查询结果共有 <bean:write name='sizeOfThis' /> 条</p>
<table>
<tr>
<td>序号</td>
<td>姓名</td>
...
</tr>
<logic:present name="targetbean">
<logic:iterate name='helperbean' id='helperbean' indexId="index">
<tr>
<td><%= index.intValue() + 1 %></td>
<td><bean:write name='helperbean' property='name' /></td>
.....
</tr>
</logic:iterate>
</logic:present>
</table>
</logic:present>
<bean:size id="sizeOfThis" scope='request' name="targetbean" />
<p align="center">查询结果共有 <bean:write name='sizeOfThis' /> 条</p>
<table>
<tr>
<td>序号</td>
<td>姓名</td>
...
</tr>
<logic:present name="targetbean">
<logic:iterate name='helperbean' id='helperbean' indexId="index">
<tr>
<td><%= index.intValue() + 1 %></td>
<td><bean:write name='helperbean' property='name' /></td>
.....
</tr>
</logic:iterate>
</logic:present>
</table>
</logic:present>
转载于:https://blog.51cto.com/77857/156842