关于jsp分页问题
这是我写的网业代码,从数据库提取数据并实现分页功能,但是系统提示出错,请大家帮忙,找了好多台秒年 实在不知道错误在哪,代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.lang.Integer"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
response.setContentType("text/html; charset=gb2312");
request.setCharacterEncoding("gb2312");
%>
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
<SCRIPT src="images/rainbow.js"></SCRIPT>
</head>
<%
int maxperpage=15;
int totalput;
int currentpage;
int totalpage;
int i,j;
String page1=request.getParameter("page");
if(request.getParameter("page")!=null)
{currentpage=Integer.parseInt(request.getParameter("page"));}
else
currentpage=1;
String sql;
ResultSet rs;
%>
<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><%@ include file="top.jsp"%></td>
</tr>
<tr background="img/back09.gif">
<td height="26" colspan="2"><table width="100%" height="26" border="0" cellpadding="0" cellspacing="0" background="img/back09.gif">
<tr>
<td width="23%" height="20" align="center" class="news02"><a href="index.jsp" class="news02">返回首页</a></td>
<td width="77%" class="news02">计划管理--局下达的综合计划</td>
</tr>
</table></td>
</tr>
<tr>
<td width="182" height="337" align="center" valign="top"><table width="95%" border="0" cellpadding="0" cellspacing="0" background="img/back0.gif">
<tr>
<td height="138" align="center" valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="img/jhgl.gif" width="177" height="61"></td>
</tr>
<tr>
<td height="66" align="left"><table width="95%" height="179" border="0" align="left" cellpadding="0" cellspacing="0" background="img/butt.gif">
<tr>
<td height="37" align="center" valign="middle" class="news02"> <a href="jhgl_zhjh.jsp" class="news02">局下达的综合计划</a></td>
</tr>
<tr>
<td height="37" align="center" valign="middle" class="news02"> 营销部的月度计划</td>
</tr>
<tr>
<td height="37" align="center" valign="middle" class="news02"> 各项生产计划</td>
</tr>
<tr>
<td height="37" align="center" valign="middle" class="news02"> 领导周(月)工作计划</td>
</tr>
<tr>
<td height="37" align="center" valign="middle" class="news02"> 班组周(月)工作计划</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="191" valign="bottom"><table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"><img src="img/back.gif" width="100%" height="9"></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="618" valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td height="388" align="center" valign="top">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<%@ include file="ConnDB.jsp"%>
<tr>
<td colspan="2"> </td>
</tr>
<%
sql="select * from jhgl_xw where lxbh=1";
rs = stmt.executeQuery(sql);
if(rs.getRow()==0){out.print("对不起,您查找的栏目暂时没有内容!");}
else
{totalput=rs.getRow();
if(currentpage<1){currentpage=1;}
if((currentpage-1)*maxperpage>totalput)
{
if ((totalput%maxperpage)==0) {currentpage= totalput/maxperpage ;}
else currentpage= totalput/maxperpage+1 ;
}
if(currentpage==1){showcontent(maxperpage);showpage(totalput,maxperpage,"jhgl_zhjh");}
else{if((currentpage-1)*maxperpage<totalput)
{
rs.absolute((currentpage-1)*maxperpage);
showcontent(maxperpage);
showpage(totalput,maxperpage,"jhgl_zhjh");
}
else{
currentpage=1;
showcontent(maxperpage);
showpage(totalput,maxperpage,"jhgl_zhjh");
}
}
}
%>
<%
public void showcontent(int p)
{
try{
int i=0;
%>
<tr> <td width="79%" height="20" class="news02"> </td>
<td width="21%" height="20" align="center" class=news02> </td>
</tr>
<tr >
<td background="images/new-bg.gif" colspan="2" class="blank1" height="1"></td>
</tr>
<%
while((rs.next())&&i<=p)
{
%>
<tr>
<td width="79%" height="32" align="left" background="img/line00.gif"> <span class="news02"> <a href="jhgl_list.jsp?bh=<%=rs.getString("bh")%>" class="news02"><%=rs.getString("bt")%></a></span></td>
<td width="21%" align="center" class="news02"><%=rs.getString("rq")%></td>
</tr>
<% i=i+1;
}
%>
<tr>
<td height="25" colspan="2" class=news02 align=right>
<%
}catch(Exception e){System.out.println(e);}}
public void showpage(int totalnumber,int maxperpage,String filename)
{ int n=0;
if ((totalPut%maxperpage)==0) {n= totalPut/maxperpage ;}
else n= totalPut/maxperpage+1 ;
%>
<form method=Post action=<%=filename%>?page1=page.value>
<%
if(current<2){out.print("首页 上一页 ");}
else
{
%>
<a href=<%=filename%>?page1="1" class=news02>首页</a>
<a href=<%=filename%>?page1=<%=Integer.toString(currentpage-1)%> class=news02>上一页</a>
<%
}
if(n-currentpage<1){
out.print("下一页 尾页");}
else
{
%>
<a href=<%=filename%>?page1=<%=Integer.toString(currentpage+1)%> class=news02>下一页</a>
<a href=<%=filename%>?page1=<%=Integer.toString(n)%> class=news02>尾页</a> 页次:<strong><font color=red><%=CurrentPage%></font><%=n%></strong>
<%
}
%>
转到:
<select name='page' size='1' style="font-size: 9pt" onChange='javascript:submit()'>
<%for(int i = 1; i<n;i++)
{
%>
<option value='<%=i%>' <%if (Integer.parseInt(Page1)==i){%> selected <%}%>><%=i%>/<%=n%></option>
<% } %>
</select>
<% } %>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><%@ include file="copy.jsp"%></td>
</tr>
</table>
</body>
</html>
<%
rs.close();stmt.close();conn.close();
%>