PageBean<Product> pageBean = new PageBean<>();
//设置当前页数
pageBean.setPage(page);
//设置每页显示的记录数
int limit = 8;
pageBean.setLimit(limit);
//设置总记录数
int totalCount = 0;
totalCount = productDao.findCountCid(cid);
pageBean.setTotalCount(totalCount);
//设置总页数
int totalPage = 0;
//Math.ceil(totalCount / limit);
if(totalCount % limit == 0){
totalPage = totalCount / limit; //totalCount = totalPage / limit;
}else {
totalPage = totalCount / limit + 1;//totalCount = totalPage / limit + 1;
}
pageBean.setTotalPage(totalPage);
//每页显示的数据集合:
// 从哪开始
int begin = (page - 1) * limit;
List<Product> list = productDao.findByPageCid(cid,begin,limit);
pageBean.setList(list);
return pageBean;
}
关于ssh分类的的pageBean的分页配置
最新推荐文章于 2024-03-21 15:59:28 发布