public List<ContractAuditListVO> pageBySubList(List list, int pagesize, int currentPage) { int totalcount = list.size(); int pagecount = 0; List<ContractAuditListVO> subList=new ArrayList<>(); int m = totalcount % pagesize; if (m > 0) { pagecount = totalcount / pagesize + 1; } else { pagecount = totalcount / pagesize; } if(((currentPage - 1) * pagesize )>=totalcount){ return subList; } if (m == 0) { subList = list.subList((currentPage - 1) * pagesize, pagesize * (currentPage)>totalcount?totalcount-1:pagesize * (currentPage)); } else { if (currentPage == pagecount) { subList = list.subList((currentPage - 1) * pagesize, totalcount); } else { subList = list.subList((currentPage - 1) * pagesize, pagesize * (currentPage)>totalcount?totalcount-1:pagesize * (currentPage)); } } return subList; }
java对list集合进行分页(适用给前台分页)
最新推荐文章于 2022-08-01 16:56:33 发布