详细的jsp分页(oracle+jsp+apache)

2016-02-19 20:18 27 1 收藏

下面是个简单易学的详细的jsp分页(oracle+jsp+apache)教程,图老师小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!

【 tulaoshi.com - Web开发 】

  我的一个详细的jsp分页程序!(oracle+jsp+apache)
  一 前提
  希望最新的纪录在开头给你的表建立查询:
  表:mytable
  查询:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列号create sequence mytable_sequence 来自动增加你的纪录id号

  二 源程序
  %String sConn="你的连接"
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn=DriverManager.getConnection(sConn,"你的用户名","密码");
  Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

  ResultSet rs=stmt.executeQuery("select * from mytable_view");
  String sqlcount="select count(*) from mytable_view";
  ResultSet rscount=stmtcount.executeQuery(sqlcount);

  int pageSize=你的每页显示纪录数;
  int rowCount=0; //总的记录数
  while (rscount
  int pageCount; //总的页数
  int currPage; //当前页数
  String strPage;
  strPage=request.getParameter("page");
  if (strPage==null){
  currPage=1;
  }
  else{
  currPage=Integer.parseInt(strPage);
  if (currPage1) currPage=1;
  }
  pageCount=(rowCount+pageSize-1)/pageSize;
  if (currPagepageCount) currPage=pageCount;

  int thepage=(currPage-1)*pageSize;
  int n=0;
  rs.absolute(thepage+1);
  while (n(pageSize)&&!rs
  %
  %rs.close();
  rscount.close();
  stmt.close();
  stmtcount.close();
  conn.close();
  %

  //下面是 第几页等
  form name="sinfo" method="post" action="sbinfo_index.jsp?condition=%=condition%&type=%=type%" onSubmit="return testform(this)"
  第%=currPage%页 共%=pageCount%页 共%=rowCount%条
  %if(currPage1){%a href="sbinfo_index.jsp?condition=%=condition%&type=%=type%"首页/a%}%
  %if(currPage1){%a href="sbinfo_index.jsp?page=%=currPage-1%&condition=%=condition%&type=%=type%"上一页/a%}%
  %if(currPagepageCount){%a href="sbinfo_index.jsp?page=%=currPage+1%&condition=%=condition%&type=%=type%"下一页/a%}%
  %if(pageCount1){%a href="sbinfo_index.jsp?page=%=pageCount%&condition=%=condition%&type=%=type%"尾页/a%}%
  跳到input type="text" name="page" size="4" style="font-size:9px"页
  input type="submit" name="submit" size="4" value="GO" style="font-size:9px"
  /form 
   

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

   完

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

来源:https://www.tulaoshi.com/n/20160219/1623291.html

延伸阅读
标签: Web开发
我们最希望任何事都是完美的,如在企业应用中,我们只需要选择一个Web平台就可以部署所有的企业应用。但往往理想与现实相去甚远。在现实世界中,信息系统往往是由很多不同的操作系统、平台以及应用环境混合而成的。而且为了保持与旧的系统兼容,系统总是将当前的技术和以前的遗留技术进行混合,这样周而复始。就使系统变得越来越复杂。 &n...
标签: Java JAVA基础
  本文只讨论如何在Windows NT 4.0上安装Apache+Servlet+Jsp。本文中的配置情况如下: Windows NT 4.0 jdk1_2_2-001-win.exe apache_1_3_12_win32.exe ApacheModuleJServ.dll tomcat.zip(3.0) 一. 软件下载 JDK http://java.sun.com/products/jdk/1.2/ Apache Server http://www.apache.org/di...
标签: Java JAVA基础
      【IT168 专稿】我们知道,JSP(JavaServer Pages)是一种动态网页技术标准。Servlet是Java技术对CGI编程的回答。     支持JSP/Servlet的WEB服务器有很多,选择合适的WEB服务器对于构建JSP网站是非常重要的。比较有名气的WEB服务器有:Allaire JRun、Apache Tomcat、BEA Weblogic Application Serv...
标签: Java JAVA基础
本文只讨论如何在Windows NT 4.0上安装Apache+Servlet+jsp。 本文中的配置情况如下: Windows NT 4.0 jdk1_2_2-001-win.exe apache_1_3_12_win32.exe ApacheModuleJServ.dll tomcat.zip(3.0) 一、软件下载 JDK http://java.sun.com/products/jdk/1.2/ Apache Server http://www.apache.org/dist/...
标签: Web开发
有热心网友回复: str += " 转到select name='page' onChange=\"window.location.href='" + fileName + temp + "cur_page='+this.options[this.selectedIndex].value\""; 已经试过了,没问题 1.以下是实现分页的类PageResultSet 代码如下: package page.bean; import java.util.*; public class PageResultSet { /** * 分页数据 */ ...

经验教程

498

收藏

82
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部