页面代码:
<table>
<tr>
<td width="50">
<s:if test="page>0">
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="page-1"/>">上一页</a>
</s:if>
<s:else>
上一页
</s:else>
</td>
<td width="150">
<s:if test="(page < countNum-2)&&countNum>3">
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="page"/>"><s:property
value="page+1" /> </a>
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="page+1"/>"><s:property
value="page+2" /> </a>
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="page+2"/>"><s:property
value="page+3" /> </a>
</s:if>
<s:elseif test="countNum>3">
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="countNum-3"/>"><s:property
value="countNum-2" /> </a>
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="countNum-2"/>"><s:property
value="countNum-1" /> </a>
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="countNum-1"/>"><s:property
value="countNum" /> </a>
</s:elseif>
<s:if test="page < countNum-1">
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="page+1"/>">下一页</a>
</s:if>
<s:else>
下一页
</s:else>
</td>
<td width="40">
<a href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=0">首页</a>
</td>
<td width="40">
<a
href="EC/user/selectUserAgoAddressList?flag=2&length=4&page=<s:property value="countNum-1"/>">尾页</a>
</td>
<td width="150">
当前是第
<s:property value="page+1" />
页
</td>
<td width="90">
总共
<s:property value="countNum" />
页
</td>
</tr>
</table>
action代码:
变量
private int start;
private int end;
private int length;
private int page;
private int countNum;
start = (page)*length;
int b= userAddressesList.size();
start=(page-1)*length;
map.put("start", String.valueOf(start));
map.put("length", String.valueOf(length));
userAddressesList = userAddressBaseService.listModel(map);
int count=userAddressesList.size();
double pageNum =((double)(b))/length;
countNum=(int)Math.ceil(pageNum);
OK! 简单实用 !! 使用场合很广