不多说直接上代码(两步解决)
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字段(总数)
