如何在jsp页面实现分页功能,而点击删除之后页码不会乱掉

解决方案 »

  1.   

    <% 
       int number=accounts.size();//オテオスノフニキハチソ
    pageCount=number%pageSize==0?number/pageSize:number/pageSize+1;//オテオスラワメウハ」ャチ橫サヨヨヒ羚ィ(number+pageSize-1)/pageSize;
    /*オテオスラワス睫・/
    //オテオスURLエォタエオトイホハ
    if(request.getParameter("page")!=null) currentPage=Integer.parseInt(request.getParameter("page"));
    currentPage=currentPage<1?1:currentPage;
    currentPage=currentPage>pageCount?pageCount:currentPage;
          %>
         
          <%if(currentPage>1){ %>
       <a href="product.jsp?page=1&action=<%=action %>">ハラ&nbsp;メウ</a>
       <a href="product.jsp?page=<%=currentPage-1 %>&action=<%=action %>">ノマメサメウ</a>
       <%} %>
       <%if(currentPage<pageCount){ %>
       <a href="product.jsp?page=<%=currentPage+1 %>&action=<%=action %>">マツメサメウ</a>
       <a href="product.jsp?page=<%=pageCount %>&action=<%=action %>">トゥ&nbsp;メウ</a>
       <%} %>
       オレ<font color="red"><%=currentPage %></font>メウ/ケイ<font color="red"><%=pageCount %></font>メウ
         
         <table width="90%" border="1" class="datalist">
    <tbody>
    <tr>
    <th scope="col">イ憘キid</th>
    <th scope="col">イ憘キテ﨤ニ</th>
    <th scope="col">イ憘キシロク・/th>
    <th scope="col">イ憘キテ靆・/th>
    <th scope="col">イ憘キヘシマ・/th>
    <th scope="col">イルラ・/th>
    </tr>
                 <%
                 if(!it.hasNext()){
                  out.print("テサモミユメオスト昕・ェオトイ憘キ");
                 }
                  else{
    for(int i=0;i<pageSize*(currentPage-1);i++){
       it.next();
       }
       for(int i=0;i<pageSize&&it.hasNext();i++){
       Product p = it.next();
    String buyActionStr = "<a href='servlet/ActionServlet?action=buy&productid="
    + p.getProduct_id() + "'>ケコツ・/a>";

    out.print("<tr>");
    out.print("<td>" + p.getProduct_id() + "</td>");
    out.print("<td>" + p.getProduct_name() + "</td>");
    out.print("<td>" + p.getProduct_price() + "</td>");
    out.print("<td>" + p.getProduct_descr() + "</td>");
    // out.print("<td>" + p.getProduct_cId() + "</td>");
    out.print("<td width='100' height='75'> <image src='img/products/" + p.getProduct_image() + "' width='100' height='75'></td>");

    out.print("<td>" + buyActionStr + "</td>");

    out.print("</tr>");
    }
    }
    %>
    </tbody>
    </table>
      

  2.   

    http://www.java3z.com/cwbwebhome/article/article1/img3/pagetest.gif这是效果