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 = "/getAllComtents",method = RequestMethod.GET)
@ResponseBody
public CommonReturnType getAllComtents(@RequestParam(defaultValue="1",required=true,value="pageNo") Integer pageNo){
//每页显示记录数
Integer pageSize=4;
//分页查询
PageHelper.startPage(pageNo, pageSize);
List<ContentsImagesModel> contentsImagesModels = contentsService.getAllContents();
PageInfo<ContentsImagesModel> pageInfo=new PageInfo<>(contentsImagesModels);
return CommonReturnType.success(pageInfo);
PageHelper.startPage(需要显示的第几个页面,每个页面显示的数量);
下一行紧跟查询语句,不可以写其他的,否则没有效果。
PageHelper.startPage(pageNo, pageSize);
List<ContentsImagesModel> contentsImagesModels = contentsService.getAllContents();
这样只起到了分页效果,对总页面数之类的没有详细信息
如果对页面数量等有需求,则需要加上下面这行
PageInfo<ContentsImagesModel> pageInfo=new PageInfo<>(contentsImagesModels);
这样就满足了全部的分页要求

Springboot整合pagehelper分页的更多相关文章
- SpringBoot集成整合pageHelper分页插件
今天来讲讲springboot 集成 pagehelper插件, 引入jar 依赖包 <!-- 分页插件 --><dependency> <groupId>com. ...
- spring boot 整合pagehelper分页插件
Spring Boot 整合pagehelper分页插件 测试环境: spring boot 版本 2.0.0.M7 mybatis starter 版本 1.3.1 jdk 1.8 ------ ...
- SpringBoot-07:SpringBoot整合PageHelper做多条件分页查询
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客讲述如何在SpringBoot中整合PageHelper,如何实现带多个条件,以及PageInfo中的 ...
- SpringBoot整合PageHelper做多条件分页查询
https://yq.aliyun.com/articles/619586 本篇博客讲述如何在SpringBoot中整合PageHelper,如何实现带多个条件,以及PageInfo中的属性的中文解释 ...
- springboot整合PageHelper
1.在pom文件中引入Pagehelper分页插件 <!-- 分页插件 --> <dependency> <groupId>com.github.pagehelpe ...
- springboot整合mybatis分页插件PageHelper
1 pom文件引入依赖 (注意:pagehelper版本不能太高,楼主之前用的5.0以上的版本,然后分页没有效果,浪费了两个小时才发现这个原因) <!-- mybatis的分页插件 --> ...
- springboot mybatis pagehelper 分页问题
1:添加依赖 compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2 ...
- springboot + mybatis +pageHelper分页排序
今天下午写查出来的数据的排序,原来的数据没有排序,现在把排序功能加上...原来用的,是xml中的sql动态传参 ,,1个小数没有弄出来,果断放弃... 网上百度一下,发现用pageHelper 可以 ...
- Springboot 使用PageHelper分页插件实现分页
一.pom文件中引入依赖 二.application.properties中配置以下内容(二选一方案) 第一种:pagehelper.helper-dialect=mysqlpagehelper.re ...
随机推荐
- windows批处理命令
前言 批处理文件(batch file)包含一系列 DOS命令,通常用于自动执行重复性任务.用户只需双击批处理文件便可执行任务,而无需重复输入相同指令.编写批处理文件非常简单,但难点在于确保一切按顺序 ...
- 读写生信流程必备的 Perl 语法
最早就是写Perl的,后来来到公司转Python,现在又要负责流程了,开始重拾Perl,当然是借鉴别人现有的语法,我再重新组合. 基本语法就不介绍了,参照我之前文章 Perl 模块 use str ...
- LeetCode--204--计数质数
问题描述: 统计所有小于非负整数 n 的质数的数量. 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 . 方法1:经典的判断是否为质数遍历( ...
- LeetCode--125--验证回文串
问题描述: 好 times out: class Solution(object): def isPalindrome(self, s): """ :type s: st ...
- 12月12日 has_many through:的interference, option
has_many :products, through: :cart_items, source: :product build定义:collection.build(attributes = {}, ...
- HDOJ1005
#include "iostream" using namespace std; int fun(int A,int B,int n) { ,y = ,z; || n == ) ; ...
- 每天一个linux命令(3):pwd
Linux中用 pwd 命令来查看”当前工作目录“的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录. 在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置. ...
- 从客户端(......)中检测到有潜在危险的 Request.Form 值
在提交表单时候,asp.net 提示:"从客户端(......)中检测到有潜在危险的 Request.Form 值" .asp.net中的请求验证特性提供了某一等级的保护措施防止X ...
- OC 归档和解档
#import <Foundation/Foundation.h> #define PATH @"/Users/mac/Desktop/file.txt" int ma ...
- Jpa实体类生成图解
Jpa实体类生成图解 创建连接 创建项目