您现在的位置是:网站首页> 编程资料编程资料

JSP实现的简单分页示例_JSP编程_

2023-05-25 333人已围观

简介 JSP实现的简单分页示例_JSP编程_

本文实例讲述了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程序设计有所帮助。

-六神源码网