jsp 分页模板
- 后台分页代码:
说明: 在 com.zc.domain 包下: PageBean.java 文件
package cn.itcast.customer.domain; ? import java.util.List; ? /** * * @author not-bug * @function: 这是用于分页的PageBean 对象 * @instructions: 这是按照面向对象的思想,进行的分页处理的操作 * 分页中的每一条记录都是一个对象,分页也就是满足某些条件的对象集合 * @param */ public { ????// 当前页的记录,通过 DAO层可以查询出来 ????private List<T> records; ? ????// 当前的页码数,从页面上传递过来的,默认第 1 页 ????private ? ????// 总页码数 ????private ? ????// 每页显示的记录条数 ????private ? ????// 总记录数(总共有多少条记录)通过 DAO可以查询出来 ????private ? ????// 当前页首行的下标 ????private ???? ????//servlet ????private String url; ? ????public String getUrl() ????{ ????????return ????} ? ????public ????{ ????????this.url = url; ????} ? ????/** ???? * @instruction:有参构造方法(提供 ???? * @param pageNow ???? * :当前页 ???? * @param totalRecords ???? * :总的记录数 ???? * @param pageSize ???? * : ???? */ ????public PageBean(int ????{ ????????this.pageNow = pageNow; ????????this.totalRecords = totalRecords; ????????this.pageSize = pageSize; ????} ? ????public PageBean() { ????} ???? ????public List<T> getRecords() ????{ ????????return ????} ? ????public ????{ ????????this.records = records; ????} ? ????public ????{ ????????return ????} ? ????// 获取总 ????public ????{ ????????this.totalPage = totalRecords / pageSize; ????????//如果取余不为 0 ,则把总页数 ????????if (totalRecords % pageSize != 0) ????????????this.totalPage++; ????????return ????} ? ????public ????{ ????????return ????} ? ????public ????{ ????????this.pageSize = pageSize; ????} ? ????public ????{ ????????return ????} ? ????public ????{ ????????this.totalRecords = totalRecords; ????} ? ????// 得到当前页首行的下标 ????public ????{ ????????this.startIndex = (pageNow - 1) * pageSize; ????????return ????} } |
?