Code instance: JSP Paging source program

Source: Internet
Author: User
js| Program | pagination

<%@ page contenttype= "text/html; charset=gb2312 "Language=" Java%>

<%@ page import = "java.util.*"%>
<%@ page import = "java.io.*"%>
<%@ page import = "java.sql.*"%>
<title> Teacher Information Inquiry </title>
<style type= "Text/css" >
<!--
. style1 {
Font-family: "XXFarEastFont-Xingkai";
Color: #FFFFFF;
}
-->
</style>
<link href= "Default.css" rel= "stylesheet" type= "Text/css" >
<style type= "Text/css" >
<!--
. style6 {
Color: #000000;
font-size:24px;
}
. style9 {FONT-SIZE:24PX}
-->
</style>
<body bgcolor= "#ffffff" >
<%session.getattribute ("A_name");%>
&LT;H1 align= "center" class= "Style1 style6 style9" > Teacher Information Inquiry <jsp:usebean id= "Tmessgebean" scope= "page" class= "Computer.sqlbean"/>
<table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" >
&LT;TR align= "center" bgcolor= "#00FFFF" >
&LT;TD colspan= "5" bgcolor= "#666666" class= "style4" ><div align= "right" ><a href= "index.html" > Return home < /a></div></td>
</tr>
&LT;TR align= "center" bgcolor= "#999999" >
&LT;TD class= "Style4" > Teaching No. </td>
&LT;TD class= "Style4" > Name </td>
&LT;TD class= "Style4" > Department </td>
&LT;TD class= "Style4" > Professional </td>
&LT;TD class= "Style4" > Operation options </td>
</tr>
<%
Request.setcharacterencoding ("gb2312");
int nowpages;//Current Page
int pages;//Request Pages
int countperpage = 10; Show number of bars per page
int pagecount;//Total Pages
int Recordcount=tmessgebean.getcounter ("SELECT count (*) from Dysf_teacher");

PageCount = (int) Math.ceil ((RecordCount + countPerPage-1)/countperpage);//Work out the total number of pages
if (Request.getparameter ("pages") = = null) {

pages = 1;
}else{
pages = new Integer (Request.getparameter ("pages")). Intvalue ();
}


if (pages > PageCount) {
Nowpages = 1;
}else{
nowpages = pages;
}

ResultSet rs = tmessgebean.executequery ("select top" + Countperpage +) * FROM Dysf_teacher where ID is not in (select Top +) (nowPages-1) *countperpage + "ID from Dysf_teacher ORDER BY id DESC", ORDER BY id DESC ");
while (Rs.next ()) {
String id = rs.getstring ("id");
String tdepartment = rs.getstring ("department");
String tspecial = rs.getstring ("special");
String tname = rs.getstring ("name");
%>
<tr>
&LT;TD width= "20%" align= "center" ><%= ID%></td>
&LT;TD width= "20%" ><div align= "center" ></div>
<div align= "center" ><%= Tname%></div></td>
&LT;TD width= "20%" ><div align= "center" ></div>
<div align= "center" ><%= tdepartment%></div></td>
&LT;TD width= "20%" ><div align= "center" ></div>
<div align= "center" ><%= tspecial%></div></td>
&LT;TD align= "center" ><a href= "atdelete.jsp?id=<%= ID%>" > Delete </a></td>
</tr>
<%
}
Rs.close ();
%>
<tr align= "Right" >
&LT;TD colspan= "5" > A total of <font color=red><%= recordCount%></font> bar record current <font color=red><% = nowpages%>/<%= PageCount%></font> page
<% if (PageCount > 1) {%>
<% if (pages > 1) {%>
<a href= "" > Home </a>
<%}if (pages < PageCount) {%>
<a href= "? pages=<%= nowpages+1%>" > next page </a>
<%}if (pages!= 1) {%>
<a href= "? pages=<%= nowPages-1%>" > Prev </a>
<%}%>
<a href= "? pages=<%= pagecount%>" > End </a>
<%}%> Jump to
<select name= "Pages" >
<% for (int i=1;i<=pagecount;i++) {%>
<option value= "<%= i%>" <% if (nowpages = i) {%>selected<%}%>><%= I%></option>
<%}%>
</select> page </td>
</tr>
</table>
</body>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.