我以前写分页都是些工具类后面偶然的机会发现了这个pagehelper在github上开源框架
maven依赖
com.github.pagehelper
pagehelper
5.1.6
只需要在service层加上然后在controller实现就好了
public Page selectCollectDataDisplay(String collectTime1, String collectTime2,
String device_name,int pageNo,int pageSize) {
HashMap map=new HashMap<>();
map.put("collectTime1",collectTime1);
map.put("collectTime2",collectTime2);
map.put("device_name",device_name);
return PageHelper.startPage(pageNo, pageSize, true)
.doSelectPage(() -> collectDataDisplayDao.selectCollectDataDisplay(map));//lambda表达式,不懂的百度
}