这是分页的javabean。显示出来的页是对的,可是点击下一页后,就会出现错误。【总计 条记录】【共 页】【条 /页】【当前第 页(列出第 到第 条记录)】 这句话不输出。只输出上一页和下一页的链接,不知道为什么。。
帮帮忙谢谢。 package bookshop;import java.sql.*;
import bookshop.DBConnection; //导入bookshop包中的数据库访问类DBConnectionpublic class PageList {
  ResultSet countRecordRs = null; //数据总记录数据集
  ResultSet pageRs = null; //分页时每页的记录数据集
  public PageList() {
  }  private int countRecord = 0; //数据表记录总数
  public int pageSize; //每页显示的记录数
  public int pageCount; //总页数
  public int pageCurrent = 0; //当前页数
  private String countSQL = null; //记录总数查询SQL语句
  private String pageSQL = null; //分页查询SQL语句
  private String strParameter = ""; //查询参数变量
  private String nowPage; //获取当前页的页号
  private String httpFile; //获取当前页的JSP页面文件
  DBConnection dbConn = new DBConnection(); //连接数据库
  //设置接收传分页参数
  public void setPages(int n) {
    pageSize = n;
  }  //获取分页查询SQL语句
  public String getPageSQL() {
    return pageSQL;
  }  /*功能:构造查询SQL语句
   *strTable :分页显示的表名
   *strWhere: 分页的where条件
   *httpfile :具体JSP页面文件
   *pages :获取地址栏传过来的pages参数
   */
  public ResultSet setQuerySQL(
      String strTable,
      String strWhere,
      String httpfile,
      String pages) throws SQLException {
    ResultSet r = null;
    this.nowPage = pages;
    this.httpFile = httpfile; //分页文件名
    countSQL = "select count(*) from " + strTable + " " + strWhere;
    pageSQL = "select * from " + strTable + " " + strWhere +
        " order by isbn desc";
    try {
      r = querySQL(countSQL, pageSQL);
    }
    catch (SQLException _ex) {
      System.out.println(_ex);
    }
    return r;
  }  /*功能:接收参数进行首尾页判断
   *countSQL :总记录的查询字符串
   *pageSQL :要分页的查询字符串
   *request :参数传递过程中的变量
   */
  public ResultSet querySQL(
      String countSQL,
      String pageSQL) throws SQLException {    //httpFile=request.getRequestURI(); //获取当前文件名
    //nowPage=request.getParameter("pages"); //获取当前页    if (nowPage == null) {
      pageCurrent = 1;
    }
    else {
      pageCurrent = Integer.parseInt(nowPage);
      if (pageCurrent < 1) {
        pageCurrent = 1;
      }
    }
    dbConn.getConnection(); //获取数据库连接
    countRecordRs = dbConn.selectRecord(countSQL); //获取数据总记录数据集
    if (countRecordRs.next()) {
      countRecord = countRecordRs.getInt(1); //获取第一个字段的整型
    }
    pageCount = (countRecord + pageSize - 1) / pageSize; //获取总页数
    if (pageCurrent > pageCount) {
      pageCurrent = pageCount; //如果当前页大于总页数,则当前页等于总页数
    }
    countRecordRs.close(); //关闭数据总记录数据集
    pageRs = dbConn.selectRecord(pageSQL); //获取执行分页的结果集
    return pageRs;
  }  //获取数据总记录数据集
  public int getCountRecord() {
    return countRecord;
  }  //获取总页数
  public int getPageCount() {
    return pageCount;
  }  //获取当前页数
  public int getPagCurrent() {
    return pageCurrent;
  }  //设置分页参数
  public void setPageFoot(String str) {
    this.strParameter += str;
  }  //设置分页栏脚注
  public String PageFooter() {
    String str = "<form action=" + httpFile + " name=form1 methord=post>";
    int next, prev;
    prev = pageCurrent - 1;
    next = pageCurrent + 1;
    str += "<font style='font-size: 9pt'>【总计<font color='blue'>"
        + getCountRecord()
        + "</font>条记录】"
        + "【共<font color='blue'>"
        + getPageCount()
        + "</font>页】";
    str += "【条"
        + pageSize
        + "/页】【当前第<font color='blue'>"
        + getPagCurrent()
        + "</font>页(列出第"
        + ( (pageSize * getPagCurrent() + 1) - pageSize)
        + "到第"
        + (getPagCurrent() * pageSize)
        + "条记录)】&nbsp;";
    //getIntPage()*pageSize
    if (pageCurrent > 1) {
      str += " <a href="
          + httpFile
          + "?pages=1"
          + strParameter
          + ">第一页</a> ";
    }
    else {
      str += " 第一页 ";
    }    if (pageCurrent > 1) {
      str += " <a href="
          + httpFile
          + "?pages="
          + prev
          + strParameter
          + ">上一页</a> ";
    }
    else {
      str += " 上一页 ";
    }    if (pageCurrent < pageCount) {
      str += " <a href="
          + httpFile
          + "?pages="
          + next
          + strParameter
          + ">下一页</a> ";
    }
    else {
      str += " 下一页 ";
    }    if (pageCount > 1 && pageCurrent != pageCount) {
      str += " <a href="
          + httpFile
          + "?pages="
          + pageCount
          + strParameter
          + ">最后页</a>";
    }
    else {
      str += " 最后页</font>";
    }
    str += "&nbsp;&nbsp;转到&nbsp;<input type='text' name='pages' size='2' style='background: #FFFFFF; border:1 solid black; color: #0033FF; font-size: 9pt;'>&nbsp;页&nbsp;<input type='submit' name='Submit' value='go' style='background: #CCCCCC; border:1 solid black; color: #0033FF; font-size: 9pt;'></form>";
    return str;
  }  //关闭数据库连接
  public void closeConn() {
    dbConn.closeConn();
  }
}