java如何实现对List集合进行分页
作者:互联网
对List集合进行分页:
private <T> Page<T> listToPage(List<T> dataList, Integer pageSize, Integer pageNumber){
Page<T> result = new Page<T>();
List<T> monitors = new ArrsyList<T>();
if(dataList!=null && dataList.size()>0){
int currentIndex = pageNumber>1?(pageNumber-1)*pageSize:0;
for(int i=0; i<pageSize &&i<dataList.size()-currentIndex;i++){
T data = dataList.get(currentIndex +i);
monitors.add(data);
}
result.addAll(monitors);
result.setTotal(dataList.size());
result.setPageNum(pageNumber);
result.setPageSize(pageSize);
result.setReasonable(true);
}
return result;
}
标签:java,分页,pageSize,dataList,List,int,pageNumber,Page 来源: https://www.cnblogs.com/mandian/p/16629752.html