1.添加pagehelper依赖

<dependency>
<groupId>org.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.3.</version>
</dependency>

2.在yml配置

# 分页查询
pagehelper:
helper-dialect: mysql
# 查询合理化,如果查询页码小于1,则按第一页查询,查询页码大于最后一页,则查询最后一页 reasonable: true

3.controller

/**
* page 你要查询第几页
* 每页多少行
*/
public Page<Map> findContexts(Integer page, Interger rows){ // 启用分页
// PageHelper中会自动帮我们生成limit 分布语句
// 以及自动帮我们执行查询总数的CountSQL
PageHelper.startPage(page, rows);
Page<Map> list = (Page)contentMapper.findAll();
return list; }
@RequestMapping("/list")
@ResponseBody
public Map list(Integer page, Integer limit){
Page<Map> p = userService.findContents(page, limit);
// layui对前台返回的数据是有格式要求的
Map result = new HashMap();
result.put("code",);
   result.put("count",page.size)
result.put("data",page);
return result;
}

Springboot- pagehelper使用的更多相关文章

  1. springboot pagehelper分页无效

    springboot pagehelper分页无效 遇到的问题把所有的数据都查出来了 -然后跟踪代码发现PageHelper.startPage没有生效,生成的sql也没有分页的信息 依赖也引入了 & ...

  2. Springboot pageHelper总结

    Springboot上使用pageHelper总结 1. 在pom.xml 中引入依赖 <!--pagehelper--> <dependency> <groupId&g ...

  3. spring-boot PageHelper

    分页插件PageHelper 参看了pagehelper-spring-boot,使用起来非常放方便,关于更多PageHelper可以点击https://github.com/pagehelper/M ...

  4. pageHelper没有分页效果的问题

    配置完全都没有问题 springboot pagehelper分页怎么都不管用 而且所有的信息记录全部都查出来了 解决方法: PageHelper.startPage(pageNum,pageSize ...

  5. 原理解密 → Spring AOP 实现动态数据源(读写分离),底层原理是什么

    开心一刻 女孩睡醒玩手机,收到男孩发来一条信息:我要去跟我喜欢的人表白了! 女孩的心猛的一痛,回了条信息:去吧,祝你好运! 男孩回了句:但是我没有勇气说不来,怕被打! 女孩:没事的,我相信你!此时女孩 ...

  6. springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件

    整合mybatis实在前面项目的基础上进行的,前面项目具体整合请参照springboot使用之一. 一.整合mybatis 整合mybatis的时候可以从mybatis官网下载mybatis官网整合的 ...

  7. SpringBoot+Mybatis+ Druid+PageHelper 实现多数据源并分页

    前言 本篇文章主要讲述的是SpringBoot整合Mybatis.Druid和PageHelper 并实现多数据源和分页.其中SpringBoot整合Mybatis这块,在之前的的一篇文章中已经讲述了 ...

  8. Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件

    前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...

  9. Spring boot入门(三):SpringBoot集成结合AdminLTE(Freemarker),利用generate自动生成代码,利用DataTable和PageHelper进行分页显示

    关于SpringBoot和PageHelper,前篇博客已经介绍过Spring boot入门(二):Spring boot集成MySql,Mybatis和PageHelper插件,前篇博客大致讲述了S ...

  10. SpringBoot整合系列-PageHelper分页插件

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9971043.html SpringBoot整合MyBatis分页插件PageHelper ...

随机推荐

  1. HashMap和ConcurrentHashMap的区别,HashMap的底层源码。

    Hashmap本质是数组加链表.根据key取得hash值,然后计算出数组下标,如果多个key对应到同一个下标,就用链表串起来,新插入的在前面. ConcurrentHashMap:在hashMap的基 ...

  2. MYSQL存储引擎介绍--应用场景

    MySQL存储引擎通常有哪3种?各自分别有什么特点?应用场景是哪些? MySQL5.5以后默认使用InnoDB存储引擎,其中InnoDB和BDB提供事务安全表,其它存储引擎都是非事务安全表.若要修改默 ...

  3. Django报:AttributeError: tuple object has no attribute get

    def index(request): hero_list=models.HeroInfo.objects.all() return render_to_response('index.html',{ ...

  4. 阿里云RDS上的一些概念性记录

    刚接触RDS,只能对RDS上的一些特性做一些笔记,方便记忆,以下为RDS上的内容摘录,取自官方文档 1 数据备份 可使用命令行或图形界面进行逻辑数据备份.仅限通过 RDS 管理控制台 或 OPEN A ...

  5. MySQL root用户忘记密码怎么办?修改密码方法:skip-grant-tables

    忘记密码怎么办? 1.以管理员身份打开cmd2.执行命令tasklist |findstr mysql ,查看正在运行的mysql进程 3.执行命令taskkill /F /PID 13644(此处进 ...

  6. npm报错npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-03-15T01_48_14_769Z-debug.log

    全局更新 npm npm i npm -g 就ok了

  7. create ‘/.git/index.lock’: File exists.

    Git – fatal: Unable to create ‘/.git/index.lock’: File exists. fatal: Unable to create ‘/path/my_pro ...

  8. OFMessageDecoder 分析

         OFMessageDecoder 继承了抽象类 FrameDecoder.FrameDecoder 会将接收到的ChannelBuffers 转换成有意义的 frame 对象.在基于流的传输 ...

  9. 剑指offer 面试49题

    面试49题: 题:丑数 题目:把只包含因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N ...

  10. 如何用好 Google 等搜索引擎

    1: 双引号短语搜索2: 减号减号前面必须是空格,减号后面没有空格,紧跟着需要排除的词例如:搜索 -引擎返回的则是包含“搜索”这个词,却不包含“引擎”这个词的结果3: 星号RE,通配符4: intit ...