……

java分页PageHelper的使用

我以前写分页都是些工具类后面偶然的机会发现了这个pagehelper在github上开源框架

maven依赖

<dependency>
  <groupId>com.github.pagehelper</groupId>
  <artifactId>pagehelper</artifactId>
  <version>5.1.6</version>
</dependency>

只需要在service层加上然后在controller实现就好了

 

public Page<CollectDataDisplay> selectCollectDataDisplay(String collectTime1, String collectTime2,
String device_name,int pageNo,int pageSize) {

HashMap<String,String > 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表达式,不懂的百度
}

posted @ 2020-01-14 14:57  来不及微笑  阅读(3786)  评论(3编辑  收藏  举报