分页
来源:互联网 发布:appstore安装不了软件 编辑:程序博客网 时间:2024/06/05 02:25
以下是jsp中调用上一页和下一页代码
<table align="center"> <tr> <td align="right"> <a href="javascript:firstPage();">首页</a> <a href="javascript:prePage();" name="prePage">上一页</a> <a href="javascript:nextPage();" name="nextPage">下一页</a> <a href="javascript:lastPage();">尾页</a> pages: 第<a name="curPage" href="javascript:renovate();" ><%=request.getAttribute("curPage").toString() %></a>页/ 共: <%=request.getAttribute("maxRowCount")%> 条/ 共: <%=request.getAttribute("maxPage")%> 页 </td> </tr></table>
在看jsp中被调用function代码
<SCRIPT language=javascript>var rowIndex = 1;function showList(){ //查询document.dataForm.action="<%=request.getContextPath()%>/master!query.action" document.dataForm.submit();}function creatHydm(){ //添加document.dataForm.action="<%=request.getContextPath()%>/master!addpage.action" document.dataForm.submit();}function delHydm(mid){ //删除if(confirm("您确定要删除此记录吗?")){document.dataForm.action="<%=request.getContextPath()%>/master!delete.action?id=${id}&mid="+mid;document.dataForm.submit();}}function firstPage(){ //首页document.dataForm.action ="<%=request.getContextPath()%>/master!queryAllByPage.action?";document.dataForm.submit();}function prePage(){ //前一页var curPage = <%=request.getAttribute("curPage") %>;prePage = curPage -1;if(prePage < 1){alert("已经是首页了");return;}document.dataForm.action ="<%=request.getContextPath()%>/master!queryAllByPage.action?&curPage="+prePage;document.dataForm.submit();}function nextPage(){ //后一页var curPage = <%=Integer.parseInt(request.getAttribute("curPage").toString())%>;var lastPage = <%=Integer.parseInt(request.getAttribute("maxPage").toString())%>;if(curPage >= lastPage){alert("已经是尾页了");return;}var nextPage = curPage + 1;document.dataForm.action ="<%=request.getContextPath()%>/master!queryAllByPage.action?curPage="+nextPage;document.dataForm.submit();}function lastPage(){ //尾页var curPage = <%=Integer.parseInt(request.getAttribute("curPage").toString())%>;var lastPage = <%=Integer.parseInt(request.getAttribute("maxPage").toString())%>;if(curPage >= lastPage){return;}document.dataForm.action ="<%=request.getContextPath()%>/master!queryAllByPage.action?curPage="+lastPage;document.dataForm.submit();}function renovate(){ //刷新document.dataForm.action ="<%=request.getContextPath()%>/master!queryAllByPage.action?&curPage=<%=request.getAttribute("curPage").toString() %>";document.dataForm.submit();}</SCRIPT>
以下是后台处理代码
public String queryAllByPage() throws ClassNotFoundException, SQLException{// 当前页//private int curPage = 1;// 共有多少页//private int maxPage;// 共有多少行//private int maxRowCount; // 每一页有多少行,默认为10行//private int rowsPerPage = 10;System.out.println("当前页:"+curPage);System.out.println("总页数:"+maxPage);System.out.println("总行数:"+maxRowCount);System.out.println("当前页显示:"+rowsPerPage);// 执行查询maxRowCount = masterService.queryCount();System.out.println("共有多少行:"+maxRowCount);maxPage = (this.maxRowCount % this.rowsPerPage == 0) ? this.maxRowCount / this.rowsPerPage : this.maxRowCount / this.rowsPerPage + 1;System.out.println("这是一共多少页:"+maxPage);list = masterService.queryAllByPage(curPage, rowsPerPage);return "query";}
public List<?> queryAllByPage(int curPage,int rowsPerPage) throws ClassNotFoundException, SQLException{// sql语句String sql = "select * from PA_SYS_MASTER LIMIT " + (curPage-1) * rowsPerPage + "," + rowsPerPage;System.out.println("这里是sql:"+sql);// 执行查询return dao.executeQueryForList(sql);}
0 0
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- 分页
- Windows Server 2008 R2 Standard升级到EnterPrise
- Makefile语法基础介绍
- C#-实验3
- Bitwise AND of Numbers Range LeetCode
- 第三周项目-1
- 分页
- linux C程序中调用shell终端的命令
- xcode4的环境变量,Build Settings参数,workspace及联编设置
- 数据结构:题目(2)在二元树中找出和为某一值的所有路径(树)
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记25 Lifecycle生命周期
- 《Effective C++》重点摘要(四)
- List中toArray()的使用方法
- Failure [INSTALL_FAILED_OLDER_SDK]报错
- Lua中强大的元方法__index详解