当前位置:Gxlcms > 数据库问题 > 分页插件pagehelper的运用(超舒服,以后再也不用在sql里写)

分页插件pagehelper的运用(超舒服,以后再也不用在sql里写)

时间:2021-07-01 10:21:17 帮助过:5人阅读

不多说直接上代码(两步解决)

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字段(总数)

分页插件pagehelper的运用(超舒服,以后再也不用在sql里写)

标签:info   hub   字段   nbsp   class   pen   group   dep   com   

人气教程排行