码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-11-10 12:03:34      阅读:137      评论:0      收藏:0      [点我收藏+]

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

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

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   

原文地址:https://www.cnblogs.com/guochenchen/p/11829279.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!