<%  
                   String currPage = request.getParameter("currPage"); //获得当前页数
                   int iCurrPage = 1 ;                                 //定义目前的页数,注意初始值不能为“0”
                   int pages = 1 ;                                     //定义总页数。
                   int allRecCount = 0 ;                               //定义表中总的记录数
                   int recPerPage = 5 ;                                //定义每页显示的记录数
                   allRecCount = HibernateUtil.findMeetingCount();     //调用工具类中方法,查询出总的记录数
                   pages = (allRecCount - 1)/recPerPage + 1 ;          //计算出总的页数
                   if(pages == 0){                                     //对页数进行有效性处理,使页数的最小值是1
                 pages = 1;
                   }
                  if(currPage != null && !currPage.equalsIgnoreCase("")){ //判断currpage是否为空
                   iCurrPage = Integer.parseInt(currPage);               //将currpage赋值给iCurrpage
                  }
                  List listMeeting =HibernateUtil.finMeeting((iCurrPage - 1) * recPerPage, recPerPage);  //调用分页方法
                   if(listMeeting.isEmpty()){
               out.println("暂无信息");                         //如果查询结果为空时,页面输出"暂无信息"
            }
                   if(!listMeeting.isEmpty() && listMeeting.size()>0){
                       for(int i= 0;i<listMeeting.size();i++){ //利用循环语句把查找的所有记录依次显示出来
                       Meeting meeting = (Meeting)listMeeting.get(i);     
                       session.getAttribute("Meeting");
                       
                       
                       
                     %>
                     <tr>
                      <td>
                   <a href="#" onClick="JScript:window.open('meeting_detail.jsp?currPage=<%=iCurrPage%>&&ID=<%=meeting.getId() %>','','width=545,height=380');return false"><%=meeting.getSubject()%></a></td>
                      <td><div align="center" class="STYLE11"><%=meeting.getCPerson()%></div></td><!--将查找出来的会议内容依次在表格中显示-->
                      <td><div align="center" class="STYLE11"><%=meeting.getMTime()%> </div></td>
                      <%  String purview = (String)application.getAttribute("Purview");      //获得将保存在application中的登录用户权限
                        if(purview.equalsIgnoreCase("只读")){                                 //如果用户的权限是"只读",将转入meeting_delno.jsp页面,不能进行删除操作。
                       %>
                       <td><div align="center">
                       <a href="meeting_delno.jsp">                                       
                       <img src="../../Images/del.gif" width="16" height="16" border="0"></td>
                       <%} %>
                       <%if(purview.equalsIgnoreCase("系统")){ %>                           <!-- 用户权限为"系统",可以进行删除操作 -->
                     <td><a href="#" onClick="JScript:window.open('meeting_del_ok.jsp?ID=<%=meeting.getId()%>&link=<%=listMeeting.size()%>&currPage=<%=iCurrPage%>','','width=550,height=350');return false">
                     <img src="../../Images/del.gif" width="16" height="16" border="0"></a>     
                    </td>
                   </tr>
                  <%}}}%>
               </table>
              </td>
            </tr>
        </table>
          <table width="100%" border="0" cellspacing="-2" cellpadding="-2" background="../../Images/main_center.jpg">
            <tr>
              <td height="25" class="STYLE2"><div align="center" class="STYLE11">      
            <%
               if(recPerPage < allRecCount){
                String href = "&nbsp;&nbsp;<a href='meeting_index.jsp?currPage="; //分页地址
                StringBuffer sbf = new StringBuffer();                            //制作分页条
               if(iCurrPage > 1){                                                 //构造上一页
               sbf.append(href+(iCurrPage - 1)+"'>上一页</a>");
              }
               for(int i = 1 ; i <= pages ; i ++){
               if(i == iCurrPage){
                 sbf.append(href+i+"'>["+i+"]</a>");                           //追加串,区分当前页
                 }
               else{                                                       
               sbf.append(href+i+"'>"+i+"</a>");
               }
              }
               if(iCurrPage < pages){
               sbf.append(href+(iCurrPage + 1)+"'>下一页</a>");                   //构造下一页
              }
                %>
               <%out.print("当前页数:["+iCurrPage+"/"+pages+"]");%>   <!-- 页面显示当前页数和总页数 -->
               <%=sbf.toString()%>                                  <!-- 将制作的分页条显示在页面上 -->
              <%}%>
String currPage = request.getParameter("currPage");里的currPage一般写在哪里呢 不用写出来吗  这是这个JSP页面的部分代码  我没找到currPage分页JSP

解决方案 »

  1.   

    http://blog.csdn.net/shadowsick
    具体项目实例可以参考我的博客,基于spring,security,struts开源
    里面有分页方案,仅供参考
      

  2.   

                      if(currPage != null && !currPage.equalsIgnoreCase("")){ //判断currpage是否为空
                       iCurrPage = Integer.parseInt(currPage);               //将currpage赋值给iCurrpage
                      }
                      List listMeeting =HibernateUtil.finMeeting((iCurrPage - 1) * recPerPage, recPerPage);  //调用分页方法
                       if(listMeeting.isEmpty()){
                   out.println("暂无信息");                         //如果查询结果为空时,页面输出"暂无信息"
                }
    楼主看这个。是传到后台的。
      

  3.   

    我没有写在jsp过.我们一般都写一个pageDao通用分页来做.只要继承他就行了.你说的那个currPage应该在Action里.因为你写页面分页还是要到Action里处理的.