Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
pages.jsp
Package: 0102010.rar [view]
Upload User: nbluoke
Upload Date: 2013-08-09
Package Size: 4851k
Code Size: 2k
Category:
Education soft system
Development Platform:
WORD
- <%@ page contentType="text/html;charset=gb2312" %>
- <%@ page import="java.sql.*"%>
- <html>
- <head>
- <title>web编程之分页显示</title>
- <body>
- <center><font color=red>用户资料表</font></center>
- <%
- int EveryPage=8;//每页显示的记录笔数;
- int OnPage=1; //显示的页数;
- int Total=0;//记录的笔数;
- int TotalPage=0;//记录的总页数;
- //下面是连接数据库;由于是简单的例子就不用JavaBean了;
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- Connection conn=DriverManager.getConnection("jdbc:odbc:test");
- Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
- String sql="select * from test";
- ResultSet rs=stmt.executeQuery(sql);
- rs.last();//移到最后一条记录;
- Total=rs.getRow();//记录的笔数;
- if(Total%EveryPage==0)
- TotalPage=Total/EveryPage;
- else
- TotalPage=Total/EveryPage+1;
- String Pages=request.getParameter("Pages");
- if(Pages!=null)
- {
- OnPage=Integer.parseInt(Pages);
- if(OnPage>TotalPage)
- {
- OnPage=TotalPage;
- }
- else if(OnPage<=0)
- {
- OnPage=1;
- }
- }
- rs.absolute((OnPage-1)*EveryPage+1);
- %>
- <center>
- 用户<%=Total%>个,共<%=TotalPage%>页当前在第<font color=red><%=OnPage%></font>页
- </center>
- <br>
- <center>
- <table border=1 bordercolor=red>
- <tr>
- <td>用户编号</td>
- <td>用户名</td>
- <td>密码</td>
- </tr>
- <%
- for(int i=1;i<=EveryPage;i++)
- {
- %>
- <tr>
- <td><%=rs.getString("id")%></td>
- <td><%=rs.getString("name")%></td>
- <td><%=rs.getString("password")%></td>
- </tr>
- <%
- if(!rs.next())
- break;
- }
- rs.close();
- stmt.close();
- conn.close();
- %>
- </table>
- </center>
- <%
- if(OnPage!=1)
- {
- %>
- <br>
- <center>
- <a href=pages.jsp?Pages=<%=1%>>第一页</a>
- <a href=pages.jsp?Pages=<%=OnPage-1%>>上一页</a>
- </center>
- <%
- }
- if(OnPage!=TotalPage)
- {
- %>
- <center>
- <a href=pages.jsp?Pages=<%=OnPage+1%>>下一页</a>
- <a href=pages.jsp?Pages=<%=TotalPage%>>最后一页</a>
- </center>
- <%
- }
- %>
- <center>
- <form action=pages.jsp method=post>
- 转到<input type="text" size=2 name=Pages value=<%=OnPage%>>页
- </form>
- </center>
- </body>
- </html>