下载是分页的代码,你把数据库连接和SQL语句改成你自己的,然后加到你的页面中就可以了。
        <%
//分页
int pageLine=10;
int totalRec=0;
int totalSub=0;
int pageNo=1;if (request.getParameter("page")!=null)
pageNo=Integer.parseInt(request.getParameter("page"));
if(pageNo<=1)
pageNo=1;try{
ResultSet countrs=null;
//指定参考行数//取得总数
countrs=info.executeQuery("select count(*) as cnt from news where newstype='community'");
if (countrs.next())
 totalRec=countrs.getInt("cnt");
countrs.close();
info.closeStmt();}
catch(Exception e){
   e.printStackTrace();
}
int totalPage=0;
totalPage=(totalSub+pageLine-1)/pageLine;
  if(pageNo>=totalPage)
  pageNo=totalPage;  
%>
        <%
      <p>&nbsp;</p>
      <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td align="center" width="38%"><b></b></td>
          <td align="center" width="17%"><font color="#FF9900"><b><font color="#F09100">∧</font></b></font> 
            <a href="community_news_list.jsp?page=<%=pageNo-1%>">上一页</a></td>
          <td align="center" width="16%"><b><font color="#F09100">∨</font><font color="ff9900"> 
            </font></b><a href="community_news_list.jsp?page=<%=pageNo+1%>">下一页</a> </td>
          <td align="center" width="29%">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" colspan="5"> 
      <% out.print("<p><br>共有"+ totalSub + "条,分为" + totalPage + "页显示  ");
 for(int j=1;j<=totalPage;j++){
   if(j%10==0) out.print("<br>");
   out.print("<a href=community_news_list.jsp?page=" + j + ">");
   if (j==pageNo)
       out.print("<font color='red'>" + j + "</font>");
   else
    out.print(j);   out.print("</a> ");
}
out.print("<br>");
%>
    </td>
  </tr>
</table>