zoukankan      html  css  js  c++  java
  • jsp实现简单的分页

    效果如下:

    <%-- Document : page Created on : 2014-11-18, 8:55:02 Author : HJZ --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <script language= "javascript"> function dumpTo(tot) { //函数参数定义时不加var,否则出错 var pageMsg = document.getElementById("pageTo").value; var patrn=/^d+$/; if (patrn.test(pageMsg)) { if(parseInt(pageMsg)<1 || parseInt(pageMsg)>parseInt(tot)) return; window.location.href="page.jsp?page=" + pageMsg; } } </script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>分页显示</title> </head> <body> <% int pageCur = 0; int pageTot = 20; int pageBegin = 0; String curPage = request.getParameter("page"); if(curPage == null) pageCur = 1; else pageCur = Integer.valueOf(curPage); pageBegin = pageCur-5; if(pageBegin < 1) pageBegin = 1; %> <talbe border="10"> <tr> <%if(pageCur!=1){%> <td> <input type="submit" name="skip" value="上一页" onclick="javascript:location.href='page.jsp?page=<%=pageCur-1%>'"> </td> <%}%> <% for(int i=pageBegin, j=1; j<=10 && i<=pageTot; ++i, ++j) {%> <%if(i == pageCur){%> <td> <%=i%> </td> <%} else {%> <td> <input type="submit" name="skip" value="<%=i%>" onclick="javascript:location.href='page.jsp?page=<%=i%>'"> </td> <%}%> <% } %> <%if(pageCur!=pageTot){%> <td> <input type="submit" name="skip" value="下一页" onclick="javascript:location.href='page.jsp?page=<%=pageCur+1%>'"> </td> <%}%> <td><%=pageTot%></td> <td width="105px"> 向第<input type="text" id="pageTo"></td> <td> <input type="button" name="skip" value="跳转" onclick="dumpTo(<%=pageTot%>)"> <!--传递总页数--> </td> </tr> </table> </body> </html>
  • 相关阅读:
    SpringBoot java.lang.IllegalArgumentException: Request header is too large
    (转)以太坊 钱包 创建 导入 Keystore
    (转)以太坊数据同步常见问题集锦
    以太坊nonce
    (转)Fabric 1.0 读写集
    (转)Fabric CA环境的集成
    Hyperledger Fabric CA的命令行用法
    oracle新建表空间与用户
    积分智能合约
    远程桌面,身份验证错误:要求的函数不正确等解决办法
  • 原文地址:https://www.cnblogs.com/hujunzheng/p/4119332.html
Copyright © 2011-2022 走看看