Springboot怎么实现整合pagehelper分页功能(pagehelper,springboot,编程语言)

时间:2024-05-09 15:35:22 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

一、添加依赖

查找maven中pagehelper的版本

在pom中添加依赖

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.2.2</version></dependency>

二、使用

网络上很多文章都会说需要在application.properties进行配置

其实完全不需要,默认的设置就已经满足大部分需要了

直接使用即可

@RequestMapping(value="getApps.do")publicStringgetApps(Appsapps){PageHelper.startPage(apps.getPageNum(),apps.getPageSize());ArrayList<Apps>appsList=appsService.getApps(apps);PageInfo<Apps>appsPageInfo=newPageInfo<>(appsList);returnJSON.toJSONString(appsPageInfo);}

PageHelper.startPage(需要显示的第几个页面,每个页面显示的数量);

下一行紧跟查询语句,不可以写其他的,否则没有效果。

PageHelper.startPage(apps.getPageNum(),apps.getPageSize());ArrayList<Apps>appsList=appsService.getApps(apps);

这样只起到了分页效果,对总页面数之类的没有详细信息

Springboot怎么实现整合pagehelper分页功能

如果对页面数量等有需求,则需要加上下面这行

PageInfo<T>appsPageInfo=newPageInfo<>(appsList);

这样就满足了全部的分页要求

Springboot怎么实现整合pagehelper分页功能

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Springboot怎么实现整合pagehelper分页功能的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:SpringBoot怎么打成war包在tomcat或wildfly下运行下一篇:

9 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18