代码实例:JSP分页源程序
2008-02-23 08:13:11来源:互联网 阅读 ()
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.io.*"%>
<%@ page import = "java.sql.*"%>
<html>
<head>
<title>教师信息查询</title>
<style type="text/css">
<!--
.style1 {
font-family: "华文行楷";
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>
</head>
<body bgcolor="#ffffff">
<%session.getAttribute("a_name");%>
<h1 align="center" class="style1 style6 style9">教师信息查询</h1>
<hr />
<jsp:useBean id="tmessgeBean" scope="page" class="computer.sqlbean"/>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="center" bgcolor="#00FFFF">
<td colspan="5" bgcolor="#666666" class="style4"><div align="right"><a href="index.html">返回首页</a></div></td>
</tr>
<tr align="center" bgcolor="#999999">
<td class="style4">教号</td>
<td class="style4">姓名</td>
<td class="style4">系别</td>
<td class="style4">专业</td>
<td class="style4">操作选项</td>
</tr>
<%
request.setCharacterEncoding("gb2312");
int nowPages;//当前页
int pages;//请求页数
int countPerPage = 10 ; //每页显示条数
int pageCount;//总页数
int recordCount=tmessgeBean.getCounter("select count(*) from dysf_teacher ");
pageCount = (int)Math.ceil((recordCount countPerPage-1) / countPerPage);//算出总页数
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 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>
<td width="20%" align="center"><%= ID %></td>
<td width="20%"><div align="center"></div>
<div align="center"><%= tname %></div></td>
<td width="20%"><div align="center"></div>
<div align="center"><%= tdepartment %></div></td>
<td width="20%"><div align="center"></div>
<div align="center"><%= tspecial %></div></td>
<td align="center"><a href="atdelete.jsp?ID=<%= ID %>">删除</a></td>
</tr>
<%
}
rs.close();
%>
<tr align="right">
<td colspan="5">共有<font color=red><%= recordCount %></font>条记录 当前<font color=red><%= nowPages %>/<%= pageCount %></font>页
<% if(pageCount > 1){ %>
<% if(pages > 1){%>
<a href="">首页</a>
<%}if(pages < pageCount){%>
<a href="?pages=<%= nowPages 1 %>">下一页</a>
<%}if(pages != 1){%>
<a href="?pages=<%= nowPages - 1 %>">上一页</a>
<%}%>
<a href="?pages=<%= pageCount %>">尾页</a>
<% } %>跳转到
<select name="pages" onChange="javascript:this.form.submit();">
<% for(int i=1;i<=pageCount;i ){%>
<option value="<%= i %>" <% if(nowPages == i){%>selected<% } %>><%= i %></option>
<% } %>
</select>页</td>
</tr>
</table>
<hr />
</body>
</html>
关键词:
【推荐给好友】【关闭】最新五条评论
查看全部评论
评论总数 0 条您的评论
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash