1 ,service 层代码实现
Integer start = (pageNum - 1) * pageSize; Integer end = pageSize; ListentityList; //调用mapper查询数据库 entityList = entityPOMapper.query(start, end); SimplePageInfo simplePageInfo = SimplePageInfo.of(entityList ); simplePageInfo.setNumber(pageNum); simplePageInfo.setPageSize(pageSize); // 查询出来数据等于size,总数据量加一,页数加一 if (entityList .size() == pageSize) { Integer totalElements = (pageNum * pageSize) + 1; Integer pages = pageNum + 1; simplePageInfo.setTotalElements(totalElements); simplePageInfo.setPages(pages); } else { //数据不够size Integer totalElements = ((pageNum - 1) * pageSize + entityList .size()); Integer pages = pageNum; simplePageInfo.setTotalElements(totalElements); simplePageInfo.setPages(pages); } return simplePageInfo; }
2,mapper
以上所述是小编给大家介绍的java仿百度假分页代码实现详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!