你这应该是想做个分页显示的吧
  我有一段代码跟你大部分是一样的,也是没有为分页写一个单独的类,都是在页面中做的
    你可以看看
<%
login=(String)session.getAttribute("login");
 username=(String)session.getAttribute("name");
if(login==null)
{
%>
<script language="javascript">
alert("您还未登录,不能浏览详细信息!!!");
</script>
<%
response.sendRedirect("login.jsp");
}
%>   <jsp:include page="top.jsp"/>
<table width="786"  border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#333333" bordercolorlight="#FFFFFF">
<tr>
  <td width="786" colspan="9">
  
      <p align="center">货物信息
    </td>
  </tr>
  <tr>
    <td width="786" height="30" colspan="9" align="right"><a href="goods_add.jsp">发布信息...</a></td>
  </tr>
  <tr align="center">
    <td width="786" height="29" align="center">货物类型</td>
    <td width="786" height="29" align="center">货物名称</td>
    <td width="786" height="29" align="center">货物数量</td>
    <td width="786" height="29" align="center">数量单位</td>
    <td width="786" height="29" align="center">起始省份</td>
    <td width="786" height="29" align="center">起始城市</td>
    <td width="786" height="29" align="center">抵达省份</td>
    <td width="786" height="29" align="center">抵达城市</td>
    <td width="786" height="29">操作</td>
  </tr>
<%
    sql="select * from tb_GoodsMeg order by IssueDate desc";
try
{
 rs=connection.executeQuery(sql);
if(!rs.next())
{
%>
<script language="javascript">
alert("没有货物信息");
</script>
<%
}else
{
rs.last();
rowcount=rs.getRow();
int showpage=1;
pagecount=((rowcount%pagesize)==0?(rowcount/pagesize):(rowcount/pagesize)+1);
 String topage=request.getParameter("topage");
if(topage!=null)
{
showpage=Integer.parseInt(topage);
if(showpage>pagecount){
  showpage=pagecount;
  }else if(showpage<=0){
  showpage=1;
  }
}
rs.absolute((showpage-1)*pagesize+1);
for(int i=1;i<=pagesize;i++)
{
n=rs.getInt("ID");
%>
<tr>
<td width="786" height="29" align="center"><%=rs.getString("GoodsStyle")%></td>
<td width="786" height="29" align="center"><%=rs.getString("GoodsName")%></td>
<td width="786" height="29" align="center"><%=rs.getString("GoodsNumber")%></td>
<td width="786" height="29" align="center"><%=rs.getString("GoodsUnit")%></td>
<td width="786" height="29" align="center"><%=rs.getString("StartProvince")%></td>
<td width="786" height="29" align="center"><%=rs.getString("StartCity")%></td>
<td width="786" height="29" align="center"><%=rs.getString("EndProvince")%></td>
<td width="786" height="29" align="center"><%=rs.getString("EndCity")%></td>
<td width="786" height="29"> <p align="center">
  <a href="goods_xiangxi.jsp?id=<%=n%>">详细</a></td>
</tr>
<%
if(!rs.next())
break;
}
%>
<tr>
    <td width="786" height="30" colspan="9" align="right"><table width="786" align="center">
<tr>
    <td width="786" height="30" colspan="9" align="right">
        共<%=pagecount%>页&nbsp;&nbsp;
        <a href="goods_select.jsp?topage=<%=1%>">第一页</a>&nbsp;&nbsp;
        <a href="goods_select.jsp?topage=<%=showpage-1%>">上一页</a>&nbsp;&nbsp;
        <a href="goods_select.jsp?topage=<%=showpage+1%>">下一页</a>&nbsp;&nbsp;
        <a href="goods_select.jsp?topage=<%=pagecount%>">最后一页</a>
</td>
</tr>
</table>
</td>
  </tr>
<%
}
}catch(Exception e)
{e.printStackTrace();}
%>

解决方案 »

  1.   

    上班中,你也没贴到底是什么错误,只是看了看连接,没时间看底下的代码,如果是连接错误的话,首先就是自己看看a标签里面的“” ‘’是否配对,外面是“”的里面就是‘’ ,第二你这么传值会出现值太长的可能就是?后你跟的变量太多了,导致?后一长串字符,而这种get提交,是有长度限制的,会把最后面多余的部分自动截取,如果是你的值太长,可能有的变量就被截取后,再下个页面取值时发生找不到变量的错误(因为没仔细看,只是提到自己的经验,希望能帮助你)
      

  2.   

    问题已解决...是 UID="+rs.getString("UID")+" & UName="+rs.getString("UName")+"  中间的 & 不应该有空格应该是
    UID="+rs.getString("UID")+"&UName="+rs.getString("UName")+"&