Struts2 数据分页

来源:互联网 发布:python rawurlencode 编辑:程序博客网 时间:2024/06/05 14:41

1、创建分页公共页面pagelist.jsp

<s:if test="pagination.tatalPage!=0"><table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td valign="bottom" align="nowrap" style="width:40%;">总记录:<s:property value="pagination.totalRecord"/>条 &nbsp;&nbsp;每页:<s:property value="pagination.size"/>条 &nbsp;&nbsp;页码:第<s:property value="pagination.currentPage"/>页/共<s:property value="pagination.totalPage"/></td><td valign="bottom" align="right" nowrap="nowrap" style="width:60%">  <s:url action"%{url}" id="first">    <s:param name="action" value="action"/>    <s:param name="pagination.currentPage" value="1"/>  </s:url>    <s:url action"%{url}" id="first">    <s:param name="action" value="action"/>    <s:param name="pagination.currentPage" value="pagination.currentPage+1"/>  </s:url>    <s:url action"%{url}" id="first">    <s:param name="action" value="action"/>    <s:param name="pagination.currentPage" value="pagination.currentPage-1"/>  </s:url><s:url action="%{url}" id="last"><s:param name="action" value="action"/><s:param name="pagination.currentPage" value="pagination.totalPage"/></s:url><s:if test="pagination.currentPage==1">  <span class="current">首页</span>  <span class="current">上一页</span></s:if><s:else><s:a href="%{first}" cssStyle="margin-right:5px;">首页</s:a><s:a href="%{prior}" cssStyle="margin-right:5px;">上一页</s:a></s:else><s:if test="pagination.currentPage==pagination.totalPage||pagination.totalPage==0">  <span class="current">下一页</span>  <span class="current">末页</span></s:if><s:else><s:a href="%{next}" cssStyle="margin-right:5px;">下一页</s:a><s:a href="%{last}" cssStyle="margin-right:5px;">末页</s:a></s:else></td></tr></table></s:if>

2、考生页面

<table cellspacing="1" border="0" id="GridView1" style="color: #333333;width:100%"><tr class="GridHeader" style="height:25px;">  <th scope="col">考生编号</th>  <th scope="col">考试号</th>  <th scope="col">考生姓名</th>  <th scope="col">手机</th>  <th scope="col">操作</th></tr><s:if test="%{stuList.size()!=0}">   <s:iterator value="%{stuList}" id="stu" status="status">   <tr <s:if test="#status.odd">class="GridDataRow"</s:if>   <s:else>class="GridAltRow"</s:else> align="center">   <td align="center">&nbsp;<s:property value="#status.count"/></td>   <td align="center">&nbps;<s:property value="#stu.stuNo"></td>   <td align="center">&nbps;<s:property value="#stu.name"></td>   <td align="center">&nbps;<s:property value="#stu.mobile"></td>   <td>   <a style="cursor:hand;" onclick="location.href='student.action?action=edit&stuNo=<s:property value="stu.stuNo">'">   <img src="../images/Edit.gif"/>   <a style="cursor:hand;"   onclick="location.href='student.action?action=del&stuNo=<s:property value="#stu.stuNo">'">   <img src="../images/del.gif"/></a>   </td>   </tr></s:iterator></s:if><s:else><tr>   <td align="center" width="100%" colspan="5">      无任何考生信息!   </td></tr> </s:else>  </table>

3、引入分页页面

<div id="page">   <jsp:include page="../commons/pagelist.jsp"/></div>
0 0