分页需要的技术点:1.前台分页标签的使用

         2.前台上一页,下一页显示的业务逻辑

         3.MSQL用到的语句  limit

         4.封装pageBean对象

这个是PageBean用到的

分页公式:

    1. int totalPageNum = (totalRecord  +  pageSize  - 1) / pageSize;
package com.itheima.vo;

import java.util.ArrayList;
import java.util.List; import com.itheima.domain.Product; public class PageBean<T> { //当前页
private int currentPage;
//当前页显示的条数
private int currentCount;
//总条数
private int totalCount;
//总页数
private int totalPage;
//每页显示的数据
private List<T> productList = new ArrayList<T>(); public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getCurrentCount() {
return currentCount;
}
public void setCurrentCount(int currentCount) {
this.currentCount = currentCount;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<T> getProductList() {
return productList;
}
public void setProductList(List<T> productList) {
this.productList = productList;
} }

前台页面上的分页标签显示逻辑

    <!--分页 -->
<div style="width: 380px; margin: 0 auto; margin-top: 50px;">
<ul class="pagination" style="text-align: center; margin-top: 10px;">
<!-- 上一页 -->
<!-- 判断当前页是否是第一页 -->
<c:if test="${pageBean.currentPage==1 }">
<li class="disabled">
<a href="javascript:void(0);" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
</c:if>
<c:if test="${pageBean.currentPage!=1 }">
<li>
<a href="${pageContext.request.contextPath }/productList?currentPage=${pageBean.currentPage-1}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
</c:if> <c:forEach begin="1" end="${pageBean.totalPage }" var="page">
<!-- 判断当前页 -->
<c:if test="${pageBean.currentPage==page }">
<li class="active"><a href="javascript:void(0);">${page}</a></li>
</c:if>
<c:if test="${pageBean.currentPage!=page }">
<li><a href="${pageContext.request.contextPath }/productList?currentPage=${page}">${page}</a></li>
</c:if> </c:forEach> <!-- 判断当前页是否是最后一页 -->
<c:if test="${pageBean.currentPage==pageBean.totalPage }">
<li class="disabled">
<a href="javascript:void(0);" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</c:if>
<c:if test="${pageBean.currentPage!=pageBean.totalPage }">
<li>
<a href="${pageContext.request.contextPath }/productList?currentPage=${pageBean.currentPage+1}" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</c:if> </ul>
</div>
<!-- 分页结束 -->

最新文章

  1. 如何在iOS9的plist文件中配置不使用https
  2. 从一个小项目看return 引用 重载运算符
  3. java远程调试(断点)程序/tomcat( eclipse远程调试Tomcat方法)
  4. Codeforces Round #311 (Div. 2)B. Pasha and Tea 水题
  5. 手机APP与原生APP设计的区别
  6. HDU3367+并查集应用
  7. ASP.NET MVC 4.0 学习4-Code First
  8. 关于bootstrap的一些想法
  9. 【3D数学基础】三维空间折射向量计算
  10. Android中FrameAnimation动画的使用
  11. if-else案例–开关灯
  12. 运输计划NOIP2015Day2T3
  13. deep learning RNN
  14. Spark 介绍
  15. 使用matlab自带工具实现rcnn
  16. 【codevs1065】01字符串
  17. 前端入门CSS(1)
  18. python里的引用、浅拷贝、深拷贝
  19. coreos 创建使用密钥登陆的ubuntu 基础镜像
  20. win10 下ie11安装flash debuger (install flashplayer debuger on win10 64bit)

热门文章

  1. 模拟windows全盘搜索
  2. rabbitMq 教程
  3. 1、CentOS部署Java开发环境
  4. SSMS登记密码清除
  5. 怎样从外网访问内网WampServer?
  6. await
  7. window bat 运行 cmd 命令
  8. Centos下10000次循环测试php对Redis和共享内存(shm)读写效率
  9. django模板继承
  10. Apache正向代理和反向代理