对List进行手动分页处理(数据量下的情况下使用) /*对List 进行分页*/ public static <T> List<T> getPageList(List<T> list,Integer page,Integer pageSize){ if (CollectionUtils.isEmpty(list)){ return Collections.emptyList(); } int count = list.size(); // 记录总数 int listPageNum = 0; // list页数 if (count % pageSize == 0){ listPageNum = count / pageSize; }else { listPageNum = count / pageSize + 1; } int fromIndex = 0; // 开始索引 int endIndex = 0; // 结束索引 if (page > listPageNum || page < 1){ /*page = listPageNum;*/ return Collections.emptyList(); } if (page != listPageNum){ fromIndex = (page -1) * pageSize; endIndex = fromIndex + pageSize; }else { fromIndex = (page -1) * pageSize; endIndex = count; } List<T> pageList = list.subList(fromIndex,endIndex); return pageList; }