日期:2014-05-18  浏览次数:20781 次

奇怪了!JSP分页问题为什么获取不到page
<%@   page   contentType= "text/html;   charset=gb2312 "   %>  
<%@   page   import= "java.sql.* "%>  
<%@   page   import= "java.io.* "%>  
<title> Jsp分页显示记录 </title> <body   bgcolor= "#ffffff ">  


<%  
//变量声明  
Connection   Con;   //数据库连接对象  
Statement   sqlStmt;   //SQL语句对象  
ResultSet   sqlRst;   //结果集对象  
String   url;   //数据库连接字符串  
String   strSQL;   //SQL语句  
int   intPageSize;   //一页显示的记录数  
int   intRowCount;   //记录总数  
int   intPageCount;   //总页数  
int   intPage;   //待显示页码  
String   strPage;  
int   i;  
String     userid;
//设置一页显示的记录数  
intPageSize   =   5;  
//取得待显示页码  

strPage   =   request.getParameter( "page ");

if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据  
intPage   =   1;  
}  
else{//将字符串转换成整型  

intPage   =   Integer.parseInt(strPage);  

if(intPage <1)   intPage   =   1;  
}  


//装载JDBC驱动程序  
try{  
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver ");  
}  
catch(ClassNotFoundException   e){out.print( "加载驱动错误 ");}  
 
//设置数据库连接字符串  
url   =   "jdbc:sqlserver://localhost:1433;DatabaseName=firstItem ";  
//连接数据库  
Con   =   DriverManager.getConnection(url, "sa ", "java ");  
//创建一个可以滚动的只读的SQL语句对象  
sqlStmt   =   Con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);  


userid   =   request.getParameter( "userid ");

//准备SQL语句  
strSQL   =   "select   *   from   [firstItem].[dbo].[userManager]   where   user_pass   =   "   +   userid   ;
//执行SQL语句并获取结果集  
sqlRst   =   sqlStmt.executeQuery(strSQL);  
//获取记录总数  
sqlRst.last();  
intRowCount   =   sqlRst.getRow();  

//记算总页数  
intPageCount   =   (intRowCount+intPageSize-1)   /   intPageSize;  
//调整待显示的页码  
if(intPage> intPageCount)   intPage   =   intPageCount;  
%>  
<%=userid%> <br>
<%=intRowCount%> <br>
<%=strPage   %>

<html>  
<head>  
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">  
<title> JSP数据库操作例程   -   数据分页显示   -   JDBC   2.0   -   MYSQL </title>  
</head>  
<body>  

<form   name= "form1 "   action= "fenye.jsp ">
<input   type= "text "   name=ss "userid "   >
<input   type= "submit "   value= "tijiao ">
</form>
<table