pagehelper 对List结果集分页
public class PageUtil { public static <T> PageInfo<T> startPage(List<T> list, Integer pageNum, Integer pageSize) { public Page<YyAccountWorehouseEntity.AccountListVo> getPage(YyAccountWorehouseEntity.QueryPage queryPage) { List<YyAccountWorehouseEntity.AccountListVo> list = yyAccountWorehouseMapper.getPage(queryPage); //创建Page类 int pageNum = queryPage.getPage(); if (pageNum == 0) { pageNum = 1; } int pageSize = queryPage.getLimit(); Page page = new Page(pageNum, pageSize); //为Page类中的total属性赋值 page.setTotal(list.size()); //计算当前需要显示的数据下标起始值 int startIndex = (pageNum - 1) * pageSize; int endIndex = Math.min(startIndex + pageSize, list.size()); //从链表中截取需要显示的子链表,并加入到Page List<YyAccountWorehouseEntity.AccountListVo> accountListVos = list.subList(startIndex, endIndex); page.setRecords(accountListVos); //以Page创建PageInfo return page; } }