分頁顯示出錯了,一定要夠pagesize的數才能正常顯示呢?
<jsp:useBean id= "diary " scope= "session " class= "user.DiaryDB ">
</jsp:useBean>
<%@ page import= "java.sql.* " %>
<%@ page contentType= "text/html;charset=BIG5 "%>
<html>
<body bgcolor= "#FFFFFF ">
<div align= "center ">
<table width= "630 " height= "430 " valign= "top " border= "1 " cellspacing= "0 " bordercolor= "#0080FF " align= "left ">
<tr>
<td valign= "top " align= "left ">
<div align= "left ">
<p> <font size= "3 " color= "#0080FF " face= "細明體 "> <b> <font size= "2 "> <a href= "newDiary.jsp "> <font color= "#0099FF "> 添加新日志 </font> </a> </font> </b> </font> </p>
<%!
int pageSize=3;//每頁顯示的條數
int pageCount=0;
%>
<form action= "diary.jsp " method= "POST ">
輸入頁碼數 <input type= "text " name= "showPage " />
<input type= "submit " value= "提交 " />
</form>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
Connection conn=DriverManager.getConnection( "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=oa ", "sa ", "sa ");
Statement stml=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stml.executeQuery( "select *from diary ");
rs.last();
int lastRow=rs.getRow();
pageCount=(lastRow%pageSize==0)?(lastRow/pageSize):(lastRow/pageSize+1);
int showPage=1;
%>
<p> 共有 <%=pageCount %> 頁 每頁顯示 <%=pageSize%> 條記錄 </p>
<%
String integer=request.getParameter( "showPage ");
if(integer==null)
{
integer= "1 ";
}