源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Springboot整合pagehelper分页功能

  • 时间:2022-05-24 18:42 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Springboot整合pagehelper分页功能
本文实例为大家分享了Springboot整合pagehelper分页展示的具体代码,供大家参考,具体内容如下 [b]一、添加依赖 [/b] [url=http://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter]查找maven中pagehelper的版本[/url] 在pom中添加依赖
<dependency>
   <groupId>com.github.pagehelper</groupId>
   <artifactId>pagehelper-spring-boot-starter</artifactId>
      <version>1.2.2</version>
</dependency>
[b]二、使用 [/b] 网络上很多文章都会说需要在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);
这样只起到了分页效果,对总页面数之类的没有详细信息 [img]http://files.jb51.net/file_images/article/201712/201712040839181.png[/img] 如果对页面数量等有需求,则需要加上下面这行
PageInfo<T> appsPageInfo = new PageInfo<>(appsList);
这样就满足了全部的分页要求 [img]http://files.jb51.net/file_images/article/201712/201712040839182.png[/img]  以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部