Springboot整合pagehelper分页功能
2017-12-04 08:36
861 查看
本文实例为大家分享了Springboot整合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") public String getApps(Apps apps) {PageHelper.startPage(apps.getPageNum(), apps.getPageSize()); ArrayList<Apps> appsList = appsService.getApps(apps); PageInfo<Apps> appsPageInfo = new PageInfo<>(appsList); return JSON.toJSONString(appsPageInfo); }
PageHelper.startPage(需要显示的第几个页面,每个页面显示的数量);
下一行紧跟查询语句,不可以写其他的,否则没有效果。
PageHelper.startPage(apps.getPageNum(), apps.getPageSize()); ArrayList<Apps> appsList = appsService.getApps(apps);
这样只起到了分页效果,对总页面数之类的没有详细信息
如果对页面数量等有需求,则需要加上下面这行
PageInfo<T> appsPageInfo = new PageInfo<>(appsList);
这样就满足了全部的分页要求
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- SpringBoot集成Mybatis并具有分页功能PageHelper
- 基于spring boot的mysql使用pagehelper实现分页功能
- spring-boot | 整合通用Mabatis 分页插件PageHelper
- Mybatis分页插件 - PageHelper与springBoot的整合
- 采用shardbatis在springBoot中实现表的水平拆分,整合swagger,mybatis,shardbatis,pagehelper
- SpringBoot分页插件PageHelper
- spring-boot 集成mybatis的分页插件PageHelper和Generator
- spring boot +Thymeleaf+mybatis 集成通用PageHelper,做分页
- Spring Boot整合PageHelper
- springboot + mybatis-pagehelper 参数查询不分页的bug。。。
- SpringBoot集成MyBatis的分页插件PageHelper(回头草)
- springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件
- SpringBoot Mybatis PageHelper分页插件的两种用法(二)
- [置顶] MyBatis基于Spring-boot集成通用Mapper以及pagehelper分页插件(含源码下载)
- SpringBoot之分页插件PageHelper的使用
- Spring Boot系列教程十一: Mybatis使用分页插件PageHelper
- maven+spring+mybatis实现分页功能PageHelper(参数方式)
- SpringBoot + Mybatis + Mapper + PageHelper + Spring Batch 整合
- SpringBoot使用PageHelper进行分页
- springboot整合mybatis和pageHelper异常问题记录