我只做显示总页数,为什么显示不出来?请大家帮看看!
没有说明错误,只显示空白.
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "
errorPage= " " %>
<%@page import= "java.io.* "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>
</head>
<body>
<%
int pageSize=5;
int pageCount=0;
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");}
catch(
ClassNotFoundException e){}
try{con=DriverManager.getConnection( "jdbc:odbc:stu ", "sa ", "sa ");
sql=con.createStatement();
rs=sql.executeQuery( "select*from student ");
rs.last();
int lastRow=rs.getRow();
pageCount=(lastRow%pageSize==0)?(lastRow/pageSize):(lastRow/pageSize+1);
%>
<table border= "1 " width= "300 " align= "center ">
<tr align= "center " bgcolor= "pink ">
<td> 学号 </td>
<td> 姓名 </td>
<td> 年龄 </td>
</tr>
<%
while(rs.next()){
String stu_id=rs.getString(1);
String stu_name=rs.getString(2);
String sex=rs.getString(3);
%>
<tr align= "center " >
<td> <%=stu_id%> </td>
<td> <%=stu_name%> </td>
<td> <%=sex%> </td>
</tr>
<%}%>
</table>
<table align= "center ">
<tr>
<td> 共 <%=pageCount%> 页 </td>
</tr>
</table>
<%
con.close();
}
catch(
SQLException e1){}
%>