主页 > 编程资料 > JSP(JAVA) >
发布时间:2016-01-01 作者:网络 阅读:315次

本文实例讲述了JSP实现的简单分页示例。分享给大家供大家参考,具体如下:

<%@ page language="java" import="java.util.*" contentType="text/html; charset=gbk"%>
<%@ page import="com.yx.page.db.*"%>
<%@ page import="java.sql.*" %>

 
  My JSP 'page01.jsp' starting page
 
 
 
<%! final String jspURL = "page04.jsp"; %> <% // 定义如下分页变量 // 1、定义每页要显示的记录数 int lineSize = 10 ; // 2、定义一个当前是第几页 int currentPage = 1 ; //接受传过来的当前页 %> <% try{ currentPage = Integer.parseInt(request.getParameter("cp")); }catch(Exception e){ e.printStackTrace(); } %> <% Connection conn = null; PreparedStatement pStmt = null; ResultSet rs = null; GetConnection getConnection = new GetConnection(); //自定义数据库连接操作 DAO %>
<% try{ String strSql= "select * from person"; pStmt = getConnection.getPreStatement(strSql); rs = pStmt.executeQuery(); %> <% for(int x=0; x<(currentPage-1)*lineSize; x++){ rs.next(); } for(int x=0; x <% } } }catch(Exception e){ %>

系统有错误

<% e.printStackTrace(); }finally{ getConnection.getAllClose(conn,pStmt,rs); } %>
编号 登陆名称 姓名 密码 操作
<%=id%> <%=uid%> <%=name%> <%=pass%> 更改 删除

希望本文所述对大家JSP程序设计有所帮助。

关键字词: