分页 jsp页面: <s:if test="currentpage==pagecount"> <s:iterator value="empss" begin="beginpage" end="empss.size()-1"> <tr class="row1"> <td><s:property value='id' /></td> <td><s:property value='name' /></td> <td><s:property value='salary' /></td> <td><s:property value='age' /></td> <td><s:property value='dept.name' /></td> <td><a title="<s:property value='id'/>" href="javascript:void(0)" class="sty1">delete emp</a> | <a href="<s:url value='/emps/emps_queryEmpsByIdAction'/>?emps.id=<s:property value='id'/>">update emp</a></td> </tr> </s:iterator> </s:if> <s:else> <s:iterator value="empss" begin="beginpage" end="endpage"> <tr class="row1"> <td><s:property value='id' /></td> <td><s:property value='name' /></td> <td><s:property value='salary' /></td> <td><s:property value='age' /></td> <td><s:property value='dept.name' /></td> <td><a title="<s:property value='id'/>" href="javascript:void(0)" class="sty1">delete emp</a> | <a href="<s:url value='/emps/emps_queryEmpsByIdAction'/>?emps.id=<s:property value='id'/>">update emp</a></td> </tr> </s:iterator> </s:else> </table> <form action="<s:url value='/emps/emps_queryEmpsByDidAction'/>" method="post"> <div class="pagination"> <s:if test="currentpage==1"> <a href="javascript:void(0)">上一页</a> </li> </s:if> <s:else> <a href="<s:url value='/emps/emps_queryEmpsByDidAction'/>?currentpage=<s:property value='currentpage-1'/>">上一页</a> </s:else> <span> <s:iterator begin="1" end="pagecount" step="1" var="pp"> <a class="currentPage" href="<s:url value='/emps/emps_queryEmpsByDidAction'/>?currentpage=<s:property value='#pp'/>"><s:property value="#pp" /></a> </s:iterator> </span> <s:if test="currentpage==pagecount"> <a href="javascript:void(0)">下一页</a> </s:if> <s:else> <a href="<s:url value='/emps/emps_queryEmpsByDidAction'/>?currentpage=<s:property value='currentpage+1'/>">下一页</a> </s:else> <span class="pageSkip"> 共<input type="text" readonly="readonly" id="in1" value="<s:property value='pagecount'/>" />页 到第<input id="pageNumber" name="currentpage" maxlength="9" οnpaste="return false;">页 <button type="button" id="butt1"> </button> </span> </form> </div> action页面: // 后台分页 public String selectPage(){ System.out.println(page); Integer p = null; if (page == null || page == ""){ p = 1; }else { p = Integer.parseInt(page); } list = es.queryByPage(p); return "selectPageOk"; } // 计算 每页的第一条 和最后一条 每页显示5条 Integer begin = (page - 1) * 5 + 1; Integer end = page * 5; // 调用dao List<Employee> list = dao.selectByPage(begin, end); return list; //前台分页 public String queryByPage(){ list = es.queryAllEmps();//查询所有 beginPage = (currentPage-1)*pageSize; endPage=currentPage*pageSize-1; if(list!=null){ pageCount = (list.size()-1)/pageSize+1; } return "queryByPageOk"; }
前后台分页
最新推荐文章于 2021-11-15 11:07:47 发布