Springboot怎么实现整合pagehelper分页功能
作者:FreshDream
时间:2023-05-11
浏览:2
一、添加依赖查找maven中pagehelper的版本在pom中添加依赖com.github.pagehelperpagehelper-spring-boot-starter1.2.2二、使用网络上很多文章都会说需要在application.properties进行配置其实完全不需要,默认的设置就已经满足大部分需要了直接使用即可@RequestMapping(value="getApps.do")publicStringgetApps(Appsapps){PageHelper.startPage(apps
本文目录
一、添加依赖
查找maven中pagehelper的版本
在pom中添加依赖
com.github.pagehelper pagehelper-spring-boot-starter 1.2.2
二、使用
网络上很多文章都会说需要在application.properties进行配置
其实完全不需要,默认的设置就已经满足大部分需要了
直接使用即可
@RequestMapping(value = "getApps.do")
public String getApps(Apps apps) {
PageHelper.startPage(apps.getPageNum(), apps.getPageSize());
ArrayList appsList = appsService.getApps(apps);
PageInfo appsPageInfo = new PageInfo<>(appsList);
return JSON.toJSONString(appsPageInfo);
} PageHelper.startPage(需要显示的第几个页面,每个页面显示的数量);
下一行紧跟查询语句,不可以写其他的,否则没有效果。
PageHelper.startPage(apps.getPageNum(), apps.getPageSize()); ArrayListappsList = appsService.getApps(apps);
这样只起到了分页效果,对总页面数之类的没有详细信息

如果对页面数量等有需求,则需要加上下面这行
PageInfoappsPageInfo = new PageInfo<>(appsList);
这样就满足了全部的分页要求

作者最新文章
漫蛙漫画官网入口更新防失效
2026-11-26 15:19
电脑微信视频一开始有声音后来没有怎么办
2026-11-25 12:18
电脑微信发语音没声音怎么办
2026-11-25 12:18
什么软件能打开微信电脑版文件
2026-11-25 12:18
鱼泡直聘查项目结算进度咋弄_鱼泡直聘结算查询法【步骤】
2026-11-25 12:18
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多

























