MySQL limit paging formula and total page calculation
Limit pagination formula: curPage is the current page; pageSize is the number of records per page
limit (curPage-1)*pageSize,pageSize
Instance
// 设置当前页显示的数据集合
int start = (currentPage - 1) * pageSize;//开始的记录数
List<Route> list = routeDao.findByPage(cid,start,pageSize,rname);
pb.setList(list);
Total number of pages = total number of records / number of records displayed per page
int totalPage = totalCount / pageSize;
Instance
int totalPage = totalCount / pageSize;
if(totalCount % pageSize == 0){
totalPage = totalCount / pageSize;
}else{
totalPage += 1;
}