萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> 代碼實例:JSP分頁源程序

代碼實例:JSP分頁源程序

<%@ 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();
}

copyright © 萬盛學電腦網 all rights reserved