我以前寫分頁都是些工具類后面偶然的機會發現了這個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表達式,不懂的百度
}