java仿百度假分页代码实现的详解
程序员文章站
2024-02-22 23:44:40
1 ,service 层代码实现
integer start = (pagenum - 1) * pagesize;
integer end = pa...
1 ,service 层代码实现
integer start = (pagenum - 1) * pagesize; integer end = pagesize; list<entity> entitylist; //调用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
<select .............> select.. from ... where ... limit #{start}, #{end} </select>
以上所述是小编给大家介绍的java仿百度假分页代码实现详解整合,希望对大家有所帮助
上一篇: 如何进行mysql的优化