JSP+Javabean+JSTL实现了记录分页显示

经过奋战,终于实现了在JSP中使用标准标签库实现记录分页显示,JSP代码为:

<%@ page language="java"
         import="java.util.*,logicprocess.ProductBean,logicprocess.PageControl"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>商品信息</title>

 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">

 <link rel="stylesheet" type="text/css" href="../common/css/bg1.css">
 

  </head>
 
  <body>
    <center>
      <h3>============所有商品的信息============</h3>
      <hr>
       <%
          String currentPage=request.getParameter("pageIndex");
          if(currentPage==null)
            currentPage="1";
          int pageIndex=Integer.parseInt(currentPage);
         
           ProductBean v=new ProductBean();
           ArrayList list=v.getAllProduct();
           PageControl pc = (PageControl)request.getAttribute("pc");
           if(pc == null){
              pc = new PageControl();
           }
           pc.setBigList(list);
           request.setAttribute("pc",pc);
           pc.setCurrentPage(pageIndex);
       %>
 <form action="viewProduct.jsp" method="POST">
     <table bgcolor="#FFDEAD" border="1" width="646">
          <tr><td >共有<%=pc.getPageSize()%>页&nbsp;&nbsp;&nbsp;&nbsp;
                                               当前第<%=pageIndex%>页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
              <td > <a href="viewProduct.jsp?pageIndex=1">首页</a> 
                   <c:if test="${pc.previousPageCount > 0}" var="true">
                          <a href="viewProduct.jsp?pageIndex=${pc.previousPageCount}">上一页</a>
                   </c:if>
                   <c:if test="${ pc.nextPagecount <= pc.pageSize}" var="true">
                          <a href="viewProduct.jsp?pageIndex=${pc.nextPagecount}">下一页</a>
                   </c:if>
                          <a href="viewProduct.jsp?pageIndex=${pc.pageSize}">尾页</a>
                 
                                                      导航:
                       <input type="text" name="pageIndex" size="10">
                       <input type="submit" name="submit" value="GO" >
                 
             </td></tr>
     </table>
 </form>
      <table  bgcolor="#E0FFFF" border="1">
          <tr> <td align="center">产品&nbsp;&nbsp;ID</td><td align="center">名&nbsp;&nbsp;称</td>
               <td align="center">产品类别ID</td><td align="center">价&nbsp;&nbsp;格</td>
               <td align="center">数&nbsp;&nbsp;量</td><td align="center">入库时间</td><td align="center">产品描述</td>
               <td align="center">更&nbsp;&nbsp;改</td><td align="center">删&nbsp;&nbsp;除</td>
          </tr>
          <c:forEach var="vc" items="${pc.smallList}">
               <tr>
                   <td><c:out value="${vc.productId}"/></td>
                   <td><c:out value="${vc.name}"/></td> 
                   <td><c:out value="${vc.categoryId}"/></td>
                   <td><c:out value="${vc.price}"/></td>
                   <td><c:out value="${vc.amount}"/></td>
                   <td><c:out value="${vc.storeTime}"/></td>
                   <td><c:out value="${vc.describe}"/></td>
                   <td><a href='modifyProduct.jsp?paramm=${vc.productId}'><font color="#0000FF">更改</font></a></td>
                   <td><a href='deleteProduct.jsp?paramm=${vc.productId}'><font color="#FF0000">删除</font></a></td>
                    
                   <td><br></td>
               </tr>
           </c:forEach>   
         </table>
       <h3><a href="index.jsp"><font color="red" size="+1">Go back</font></a></h3>
    </center>
  </body>
</html>

 

效果图:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值