java仿百度假分页代码实现的详解
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仿百度假分页代码实现详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对CodeAE代码之家网站的支持!
文档来源:http://www.zzvips.com/article/179374.html
页:
[1]