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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM