好不容易弄了个分页,第一页显示正常,把我高兴坏了,可按下一页的时候就出现问题了,呜呜应该是参数没有传递到第二页,请大家帮帮忙!!!第一页正常:
        车次:k71  
途经站 出发站  终点站  出发时间  到达时间  里程  票型  票价  
  1      hz       zj   16:45     17:50     300   yz     60  
  2      hz       xz   16:45     17:55     500   yz     70  
  3      hz       xt   16:45     18:20     590   yz     80  
 
   当前页数:[1/2]  后一页 最后一页  第二页:
            车次:null  
途经站 出发站  终点站  出发时间  到达时间  里程  票型  票价  
   当前页数:[1/0]   就没东西了,呜呜!!!!
代码:
<body>
<table align="center" width="80%">
<tr height="40">
<td colspan="7" align="center" height="40">
车次:<%=request.getParameter("train_no")%>
</td>
</tr>
<tr height="40">
<td align="center">
途经站
</td>
<td align="center" width="10%">
出发站
</td>
<td align="center" width="10%">
终点站
</td>
<td align="center" width="15%">
出发时间
</td>
<td align="center" width="15%">
到达时间
</td>
<td align="center" width="10%">
里程
</td>
<td align="center" width="15%">
票型
</td>
<td align="center" width="15%">
票价
</td>
</tr>
<%
String train_no = request.getParameter("train_no"); connDB d = new connDB();
ResultSet rs = d
.executeQuery("select * from train_info  where train_no='"
+ train_no + "' order by mileage");
int count = 0;
String str = (String) request.getParameter("Page");
if (str == null) {
str = "0";
}
int pagesize = 3;
rs.last();
int RecordCount = rs.getRow();
int maxPage = 0;
maxPage = (RecordCount % pagesize == 0) ? (RecordCount / pagesize)
: ((RecordCount / pagesize) + 1);
int Page = 0;
try {
Page = Integer.parseInt("str");
} catch (Exception e) {
}
if (Page < 1) {
Page = 1;
} else {
if (Page > maxPage) {
Page = maxPage;
}
}
rs.absolute((Page - 1) * pagesize + 1);
for (int i = 1; i <= pagesize; i++) {
if (rs.next()) {
String start = rs.getString("start");
String end = rs.getString("end");
String mileage = rs.getString("mileage");
String stime = rs.getString("stime");
String etime = rs.getString("etime");
String ticket_type = rs.getString("ticket_type");
String ticket_price = rs.getString("ticket_price");
%> <tr height="30">
<td align="center"><%=++count%></td>
<td align="center">
<%=start%>
</td>
<td align="center">
<%=end%>
</td>
<td align="center">
<%=stime%>
</td>
<td align="center">
<%=etime%>
</td>
<td align="center">
<%=mileage%>
</td>
<td align="center">
<%=ticket_type%>
</td>
<td align="center">
<%=ticket_price%>
</td>
</tr>
<%
}
}
%>
</table>
<table width="100%">
<tr align="center" width="30">
<td>
当前页数:[<%=Page%>/<%=maxPage%>]&nbsp;
<%
if (Page > 1) {
%>
<a href="no.jsp" ?Page=1">第一页</a>
<a href="no.jsp?Page=<%=page%>">上一页</a>
<%
}
if (Page < maxPage) {
%>
<a href="no.jsp?Page=<%=Page + 1%>">后一页</a>
<a href="no.jsp?Page=<%=maxPage%>">最后一页</a>
<%
}
%>
</td>
</tr>
</table>
</body>

解决方案 »

  1.   

    第二页: 
                车次:null  可能没传这个参数?
    车次: <%=request.getParameter("train_no")%> 
    第一次,从哪得到的?
      

  2.   

    给你看看我写的一个分页的吧!希望对你有帮助!
    showProductLists.jsp
    //一个小脚本
    <%
    ProductDao p=new ProductDao();
    int pages;
    int row=p.findProductcount();//获取数据库商品总条数
    int pe=(row%5==0)?row/5:(row/5)+1;



    String  tpages=request.getParameter("pages");
    if (tpages!=null){
    pages = Integer.parseInt(tpages);
    if(pages>pe){
     pages=pe;
    }else if(pages<1){
    pages=1;
    }
    }else{
     pages=1;
    }
    %>//这里是显示商品信息的
      <%
    List li=p.findProducts(pages);
    for(int i=0;i<li.size();i++){
    Product pr=(Product) li.get(i); 
     %>
    <%=pr.商品的字段 %> <%
      
      }
       %>//这里是点击上下页
          <td width="69"><a href="showProductLists.jsp?pages=<%=pages-1 %>">上一页</a></td>
          <td width="79"><a href="showProductLists.jsp?pages=<%=pages+1 %>">下一页</a></td>//后台的查询代码ProductDao.java
    /**
     * 产品的列表
     */
    public List findProducts(int page){
    List list=new ArrayList(); 
    int row=0;
    if(page>1){
    row=5*(page-1);
    }
    String sql="select  top 5 * from product where productid not in (select  top "+row+" productid from product  order by  productid  desc )   order by  productid  desc";

    try {
    con=super.getConnection();
    pst=con.prepareStatement(sql);
    rs=pst.executeQuery();
    while(rs.next()){
    Product product=new Product();
        product.setProductId(rs.getInt("productId"));//编号
    product.setImage(rs.getString("image"));//图片
    product.setBrand(rs.getString("brand"));//型号
    product.setPrice(rs.getInt("price"));//价格
    product.setType(rs.getString("type"));//类型
    product.setName(rs.getString("name"));
    product.setDescription(rs.getString("description"));



    list.add(product);
    }

    } catch (SQLException e) {
    e.printStackTrace();
    }finally{
    super.closeAll();
    }

    return list;
    }
      

  3.   

    <% 
    if (Page > 1) { 
    %> 
    <a href="no.jsp" ?Page=1&train_no<%=request.getParameter("train_no")%>">第一页 </a> 
    <a href="no.jsp?Page= <%=page%>&train_no<%=request.getParameter("train_no")%>">上一页 </a> 
    <% 

    if (Page < maxPage) { 
    %> 
    <a href="no.jsp?Page= <%=Page + 1%>&train_no<%=request.getParameter("train_no")%>">后一页 </a> 
    <a href="no.jsp?Page= <%=maxPage%>&train_no<%=request.getParameter("train_no")%>">最后一页 </a> 
    <% 

    %> 这样就可以了,楼主的代码惨不忍睹啊,哈哈,跟ASP的一样。
      

  4.   

    <% 
    if (Page > 1) { 
    %> 
    <a href="no.jsp" ?Page=1&train_no=<%=request.getParameter("train_no")%>">第一页 </a> 
    <a href="no.jsp?Page= <%=page%>&train_no=<%=request.getParameter("train_no")%>">上一页 </a> 
    <% 

    if (Page < maxPage) { 
    %> 
    <a href="no.jsp?Page= <%=Page + 1%>&train_no=<%=request.getParameter("train_no")%>">后一页 </a> 
    <a href="no.jsp?Page= <%=maxPage%>&train_no=<%=request.getParameter("train_no")%>">最后一页 </a> 
    <% 

    %> 
      

  5.   

    让大家见笑了哈,我刚学JSP啦。。嘿嘿。/、。