分頁插件pagehelper的運用(超舒服,以后再也不用在sql里寫)


不多說直接上代碼(兩步解決)

1.pom引入依賴

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

2.運用

PageHelper.startPage(pageNum,pageSize);
List<Product> products = ProductService.selectProductList();
PageInfo<Product> productsPageInfo = new PageInfo<>(products);

只需要接受前端的PageNum(當前頁),PageSize(一頁顯示的數量)  得到的結果集中 會有一個total字段(總數)


免責聲明!

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



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