jsp分页组件的使用
2011-04-21 10:16
274 查看
可以单独写一个分页组件 eg:
此组件动态包含于含有列表的jsp中。
eg :list.jsp 此页面中要定义出cp,ls,count,其中count需要在EmpDAOImpl中获得,传进参数cp,ls使用数据库
真分页查找 (sqlserver中用top关键字),在页面中注意动态包含之前也有 cp=request.getParameter("cp")
..一定要注意,否则无法跳转,因为cp,ls,有默认值了
为了复习方便,把list.jsp贴出来
<% int cp = Integer.parseInt(request.getParameter("cp")); int ls = Integer.parseInt(request.getParameter("ls")); int count = Integer.parseInt(request.getParameter("count")); String URL = request.getParameter("URL"); int allPage = (count -1)/ls +1; int[] allLs = {2,5,10,20,50}; %> <center style="font-size:13px; " mce_style="font-size:13px; "> <form action="<%=URL %>" id="myform"> <input type="button" value="首页" onclick="changeCp(1);" /> <input type="button" value="上一页" <%=cp == 1 ? "disabled" : ""%> onclick="changeCp(<%=cp-1 %>);" /> <input type="button" value="下一页" <%=cp == allPage ? "disabled" : ""%> onclick="changeCp(<%=cp+1 %>);" /> <input type="button" value="末页" onclick="changeCp(<%=allPage %>);" /> 跳转到<input type="text" value="<%=cp%>" name="cp" size="2" id="cp"/>/<%=allPage %> <input type="submit" value="转到" /> 每页显示 <select name="ls" onchange="changeLs();"> <% for(int i=0;i<allLs.length;i++){ %> <option value="<%=allLs[i] %>" <%=allLs[i]==ls?"selected":"" %>><%=allLs[i] %></option> <% } %> </select> 条记录 </form> </center> </body> <script type="text/javascript"> function changeLs() { document.getElementById("cp").value = 1; document.getElementById("myform").submit(); } function changeCp(cp) { document.getElementById("cp").value = cp; document.getElementById("myform").submit(); } </script>
此组件动态包含于含有列表的jsp中。
eg :list.jsp 此页面中要定义出cp,ls,count,其中count需要在EmpDAOImpl中获得,传进参数cp,ls使用数据库
真分页查找 (sqlserver中用top关键字),在页面中注意动态包含之前也有 cp=request.getParameter("cp")
..一定要注意,否则无法跳转,因为cp,ls,有默认值了
为了复习方便,把list.jsp贴出来
<table style="BORDER-COLLAPSE: collapse; font-size:13px;" mce_style="BORDER-COLLAPSE: collapse; font-size:13px;" bordercolor="#FF6600" height=40 cellPadding=1 width=600 align=center border=1> <tr bgcolor="#F6F6F6" align="center" style=" font-weight:bold;" mce_style=" font-weight:bold;" > <td>职工号</td> <td>姓 名</td> <td>性 别</td> <td>年 龄</td> <td>工 资</td> <td>住 址</td> <td>删 除</td> <td>更 新</td> </tr> <% int cp = 1; int ls = 5; try{ cp = Integer.parseInt(request.getParameter("cp")); ls = Integer.parseInt(request.getParameter("ls")); }catch(NumberFormatException e) { } Map map = ServiceFactory.getEmpServiceInstance().findAllSplit(cp,ls); List<Emp> allEmp = (List)map.get("allEmp"); int count = (Integer)map.get("count"); %> <jsp:include page="split.jsp"> <jsp:param value="<%=cp %>" name="cp"/> <jsp:param value="<%=ls %>" name="ls"/> <jsp:param value="<%=count %>" name="count"/> <jsp:param value="select.jsp" name="URL"/> </jsp:include> <% if(allEmp != null) { Iterator<Emp> it = allEmp.iterator(); while(it.hasNext()) { Emp emp = it.next(); %> <tr align="center"> <td><%=emp.getEno()%></td> <td><%=emp.getEname()%></td> <td><%=emp.getEsex()%></td> <td><%=emp.getEage()%></td> <td><%=emp.getEwage()%></td> <td><%=emp.getElocal()%></td> <td><a href="delete.jsp?=<%=emp.getEno() %>" onclick="return window.confirm('确认删除?');">删除</a></td> <td><a href="update.jsp?=<%=emp.getEno() %>">修改</a></td> </tr> <% } } %> </table><br /> </div>
相关文章推荐
- JSP通用分页组件 pager-taglib使用
- JSP通用分页组件 pager-taglib使用
- JFinal使用JSP写的分页组件
- 使用Jmesa分页组件在jsp里总的页数totalRows
- jsp分页(使用sql语句实现,并非easyui的json)
- 【转】在jsp中使用smartupload组件上传文件
- 对html或jsp文章列表页面进行js分页,结合使用apache的url Rewrite和jquery
- jspSmartUpload 组件的使用方法
- 在jsp中使用smartupload组件上传文件
- 使用jquery编写一个分页组件(部分内容并不通用,以后需改善)
- 使用easyUi技术的datagrid组件实现条件分页
- jspSmartUpload 组件的使用方法
- jspsmartupload组件使用(二)相关类说明篇 ---转
- 使用jspsmartupload组件在servlet里面上传文件
- FineUIMvc表格数据库分页,使用CYQ.Data组件
- JspSmartUpload组件的使用说明
- 使用smartupload组件实现jsp+jdbc上传下载文件实例解析
- vuejs2.0实现分页组件,使用$emit进行事件监听数据传递
- vuejs2.0实现分页组件使用$emit进行事件监听数据传递的方法
- JSP 开发之Spring BeanUtils组件使用