if(currPage > pageCount){ currPage = pageCount; } if(currPage < 1){ currPage = 1; } if(currPage < 2){ addr += "首 页 上一页 "; } else{ addr += "<a href=" + filename + "page=1>首 页</a> "; addr += "<a href=" + filename + "page=" + (currPage - 1) + ">上一页</a> "; } if(currPage >= pageCount){ addr += "下一页 尾 页 "; } else{ addr += "<a href=" + filename + "page=" + (currPage + 1) + ">下一页</a> "; addr += "<a href=" + filename + "page=" + pageCount + ">尾 页</a> "; } addr += "转到:<select name=´page´ size=´1´ style=´font-size: 9pt´ onChange=´javascript :pageform.submit()´> "; for(int i = 1; i <= pageCount; i ++){ if(currPage==i){ addr += "<option value=" + i + " selected> 第 "+i+"页 </option > "; } else{ addr += "<option value=" + i + "> 第 "+i+"页 </option > "; } } addr += "</select></div></td></tr></form></table>"; return addr; } /** 关闭数据集 */ public void closestmt() { try{ stmt.close(); }catch(SQLException ex) { System.err.println("数据集关闭错误:"+ex.getMessage()); } } /** 关闭数据库连接 */ public void closeconn() { try{ conn.close(); }catch(SQLException ex) { System.err.println("数据库连接关闭错误:"+ex.getMessage()); } } } 其中的JSP页面中的代码大家自己动手写!很容易的! http://blog.csdn.net/goldbox/archive/2007/01/26/1494667.aspx |