首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

第一回点查询可以正常显示结果,但是第二次点查询就报错

2012-12-17 
第一次点查询可以正常显示结果,但是第二次点查询就报错。%@ page contentTypetext/html charsetgb2312

第一次点查询可以正常显示结果,但是第二次点查询就报错。
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>信息搜索结果</title>


</head>

<body>
<jsp:include page="search.html"/>



<%
Connection conn=null;
ResultSet rsAll=null;
Statement stmt=null;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:car","sa","123");

stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String strItem=request.getParameter("item");
String strContent=request.getParameter("content");
String strSql="";
if(strItem==null||strItem=="")
{
strSql="select cid,fid,chj,zzh,zw FROM [car].[dbo].[car_info]";
}
else
{
 strSql="select cid,fid,chj,zzh,zw FROM [car].[dbo].[car_info] where "+strItem.trim()+" Like '%"+strContent.trim()+"%'";
}

rsAll=stmt.executeQuery(strSql);

}
catch(Exception e)
{
e.printStackTrace();
}

%>

<table width="100%" border="1" cellpadding="0" align="center">
<tr>
<td><font size="2" color="#0000ff">车牌号</font></td>
<td><font size="2" color="#0000ff">发动机编号</font></td>
<td><font size="2" color="#0000ff">生产厂家</font></td>
<td><font size="2" color="#0000ff">载重</font></td>
<td><font size="2" color="#0000ff">座位数</font></td>
</tr>


<%

int pagesize=5;
int maxPage=0;
String str=(String)request.getParameter("page");
if(str==null)
{
str="0";
}
rsAll.last();
int recordCount=rsAll.getRow();
maxPage=(recordCount%pagesize==0)?(recordCount/pagesize):(recordCount/pagesize+1);


int currentPage=Integer.parseInt(str);
if(currentPage<1)
{
currentPage=1;
}
else
{
if(currentPage>maxPage)
{
currentPage=maxPage;
}
}
rsAll.absolute((currentPage-1)*pagesize+1);
for(int i=1;i<=pagesize;i++)
{
%>

<tr>
<td><font size="2"><%= rsAll.getString("cid")%></font></td>
<td><font size="2"><%= rsAll.getString("fid")%></font></td>
<td><font size="2"><%= rsAll.getString("chj")%></font></td>
<td><font size="2"><%= rsAll.getString("zzh")%></font></td>
<td><font size="2"><%= rsAll.getString("zw")%></font></td>
<td><a href="#"><font size="2">修改</font></a></td>
<td><a href="#"><font size="2">删除</font></a></td>
</tr>

<%
try
{
if(!rsAll.next())
{break;}
}
catch(Exception e){}
}
%>

</table>
<p align="center"><font size="2">跳转到:<input type="text" name="page" size="3" />


当前页数:[<%= currentPage%>/<%= maxPage%>]&nbsp;

<a href="search_result.jsp?page=1">第一页</a>
<a href="search_result.jsp?page=<%= currentPage-1%>">上一页</a>

<a href="search_result.jsp?page=<%= currentPage+1%>">下一页</a>
<a href="search_result.jsp?page=<%= maxPage%>">最后一页</a>

<%

rsAll.close();
stmt.close();
conn.close();
%>
</font>
</p>

</body>
</html>
[解决办法]

这是报错信息
type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Exception in JSP: /search_result.jsp:73

70: maxPage=(recordCount%pagesize==0)?(recordCount/pagesize):(recordCount/pagesize+1);
71: 
72: 
73: int currentPage=Integer.parseInt(str);
74: if(currentPage<1)
75: {
76: currentPage=1;


热点排行