将参数start,limit,Service层返回的符合条件的list集合传入自定义方法中,返回pageInfo即可(如下所示)
##Controller层
PageInfo<T> pageInfo = pageSet(start,limit,list);
##自定义方法
public PageInfo<T> pageSet(int start, int limit, List<T> list) {
Page page = new Page(start, limit);
int total = list.size();
page.setTotal(total);
int startIndex = start/limit * limit;
int endIndex = Math.min(startIndex + limit,total);
page.addAll(list.subList(startIndex,endIndex));
PageInfo pageInfo = new PageInfo<>(page);
return pageInfo;
}
标签:java,Service,int,层中,list,page,start,limit,pageInfo
From: https://www.cnblogs.com/LL-6/p/17075698.html