jsp分页,第一页正常现实,点击下一页之后出现空白,然后点上一页又正常显示第一页,请问是什么原因?

解决方案 »

  1.   

    第一页有显示的嘛,那肯定读出了吧?不过我发现点下一页之后没有去执行rs.next()循环内的代码,不知道为什么
      

  2.   

     <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="30" colspan="2" style="font-size:12px; padding-top:10px;">位置:<a href="../servlet/BBSServlet">同圣社区</a></td>
        </tr>
        <tr>
          <td height="40" colspan="2" style="font-size:12px; padding-top:10px;">
          <a href="../jsp/reply.jsp">
           <img src="../images/reply.gif" width="57" height="33" style="border:0"></a>
           <a href="../jsp/new.jsp"><img src="../images/button.gif" style="border:0"></a></td>
        </tr>
        <tr>
        <%
         ResultSet rs=(ResultSet)request.getSession().getAttribute("detials");
         while(rs.next()){
         String title=rs.getString("Title");
         String photo=rs.getString("Photo");
         String content=rs.getString("Content");
         String author=rs.getString("Author");
         //System.out.println(photo);
        %>
        
           <td colspan="2" height="25px" style="font-size:12px; padding-left:10px;background-image:url(../images/bg.gif)"><%=title%></td>
         </tr>
         <tr>
          <td width="177" height="63" style="font-size:12px; padding-top:10px;background-image:url(../images/bgimage.jpg)" align="center">
          <%=author %><br>
          <img src="<%=photo %>" align="middle">
          </td>
           <td width="792" style="font-size:12px; padding-top:10px;background-image:url(../images/bg1.jpg)">
            <%=content %>
     </td>
        </tr>
        
        <% 
         }
        
        %>
         <tr>
         <%
        int intPageSize; //一页显示的记录数
    int intRowCount; //记录总数
    int intPageCount; //总页数
    int intPage; //待显示页码
    java.lang.String strPage;

    //设置一页显示的记录数
    intPageSize = 5;
    //取得待显示页码
    strPage = request.getParameter("page");
    //System.out.println(strPage);
    if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
    intPage = 1;
    }
    else{//将字符串转换成整型
    intPage = java.lang.Integer.parseInt(strPage);
    if(intPage<1) intPage = 1;
    }
    DBConn conn=new DBConn();
    Integer  id=(Integer )request.getSession().getAttribute("id");
    String sqlString="select * from Reply where Pid="+id;
    ResultSet rset=conn.eQuery(sqlString);
    //获取记录总数
    rset.last();//光标在最后一行
    intRowCount = rset.getRow();//获得当前行号
    if(intRowCount%intPageSize==0)
    intPageCount=intRowCount/intPageSize;
    else
    intPageCount=intRowCount/intPageSize+1;
    //把纪录指针移至当前页第一条记录前
    if((intPage-1)*intRowCount==0)
    rset.beforeFirst();
    else
    rset.absolute((intPage-1)*intRowCount);
    //记算总页数
    intPageCount = (intRowCount+intPageSize-1) / intPageSize;
    System.out.println(intPageCount);
    //调整待显示的页码
    if(intPage>intPageCount) intPage = intPageCount;

          %>
          <%
          //ResultSet rs1=(ResultSet)request.getAttribute("reply");
          int i=0;
          while(rset.next())
          {
          int userid=rset.getInt("AuthorId");
          String content=rset.getString("Content");
          String sql="select * from ts_user where userbh="+userid;
         
          ResultSet rSet=conn.eQuery(sql);
          String photo=null;
          String name=null;
          while(rSet.next()){
          photo=rSet.getString("userphoto");
          name=rSet.getString("username");
          System.out.println(name);
          }
          i++;
         
          %>
          <td width="177" height="63" style="font-size:12px; padding-top:10px;background-image:url(../images/bgimage.jpg)" align="center">
          <%=name %><br>
          <img src="<%=photo %>" align="middle">
          </td>
           <td width="792" style="font-size:12px; padding-top:10px;background-image:url(../images/bg1.jpg)">
            <%=content %>
     </td>
        </tr>
        
        
         <% 
         if(i>=intPageSize) break;
          }
          %>
         
        
     </table>
         <form action="../servlet/ReplyServlet" method="post" name="form2">
        <table style="float:left">
        <tr> 
          <td height="64" colspan="2" valign="top" style="font-size:12px; padding-top:10px; ">
          <p> 快速回复
            <textarea name="content" id="textarea" cols="45" rows="5"></textarea>
          </p>
          <p>
     
            <input type="submit" value="" class="submitStyle" style="width:100px;height:35px" />
          </p>
         </td> 
        </tr>
      </table>
        </form>
      <form method="POST" action="publish.jsp">
    第<%=intPage%>页  共<%=intPageCount%>页

    <%if(intPage>1){%><a href="../jsp/publish.jsp?page=<%=intPage-1%>">

    上一页</a><%}%>
      <%if(intPage<intPageCount){%><a href="../jsp/publish.jsp?page=<%=intPage+1%>">下一页

    </a><%}%>  
    转到第:<input type="text" name="page" size="8"> 页
    <span><input class=buttonface type=submit  value=GO name=cndok></span>
    </form>
         
     </div>
         <div class=d1></div>
        <%@include file="/jsp/footer.jsp" %>
    </center>
    </BODY>
    代码有点乱,见谅!
      

  3.   

    这种问题肯定是算错了  或者sql拼错了,检查一下就行了啊。