例一:
/*
* 在java代码中实现分页
*/
int start = (pageNo-1) * pageSize;
int end = pageNo * pageSize;
if(end >= qualityReportVos1.size()){
end = qualityReportVos1.size();
}
for(int i = start; i < end; i ++){
qualityReportVos2.add(qualityReportVos1.get(i));
}
return qualityReportVos2;
只记录部分内容;对查询出的集合进行分页,然后把当页的数据放入一个新的集合返回;
例二:
Map<String,Object> resultMap = new HashMap<>();
Integer pageSize = Integer.valueOf(ConfigUtil.getConfig("limit"));
int totalRecord = list.size();
int nowPage = Integer.parseInt(curPage);
Page page = new Page(totalRecord, nowPage);
List<OtherStorageRepertoryQualityVO> listOne = new ArrayList<>();
for (int i = pageSize*(nowPage-1); i < pageSize*(nowPage-1)+pageSize; i++) {
if(i<list.size()) {
listOne.add(list.get(i));
}
}
resultMap.put("page", page);
resultMap.put("list", listOne);