Mybatis的分页插件PageHelper分页失效的原因
引用博客:个人博客地址:https://alexaccele.github.io/
PageHelper是Mybatis的一个很好的分页插件,但要使用它的分页功能需要注意一下几点
1.导入相关包,例如maven导入依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.4</version>
</dependency>
2.在mybatis-config.xml中添加插件
引入 pageHelper插件
注意这里要写成PageInterceptor, 5.0之前的版本都是写PageHelper, 5.0之后要换成PageInterceptor
reasonable:分页合理化参数,默认值为false。
当该参数设置为 true 时,pageNum<=0 时会查询第一页,
pageNum>pages(超过总数时),会查询最后一页。
默认false 时,直接根据参数进行查询。
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!--分页参数合理化 -->
<property name="reasonable" value="true"/>
</plugin>
</plugins>
3.在Controller的方法中
PageHelper.startPage(1,5);//从第一页开始,每页5条记录
以上代码后面需紧跟查询语句
List<Test> tests = testService.getAllTestsByTypeId(testTypeid);
PageInfo pageInfo = new PageInfo(tests,5);
当一个方法中有多个查询语句时,只有紧跟在PageHelper.starPage()方法后的查询结果才会分页。
缺少以上三步都会导致分页失效
参考:https://www.cnblogs.com/smfx1314/archive/2018/04/23/8920278.html
Mybatis的分页插件PageHelper分页失效的原因的更多相关文章
- 10—mybatis 通用mapper插件 pagehelper 分页
spring boot真的太好用了,大家以后多多使用,今天来说说pagehelper 来做mybatis分页,我用的是spring boot 做的开发,后面会把源码发出来. pagehelper(ht ...
- Mybatis的分页插件PageHelper
Mybatis的分页插件PageHelper 项目地址:http://git.oschina.net/free/Mybatis_PageHelper 文档地址:http://git.oschina. ...
- mybatis分页插件PageHelper的使用(转)
Mybatis 的分页插件PageHelper-4.1.1的使用 Mybatis 的分页插件 PageHelper 项目地址:http://git.oschina.net/free/Mybatis_P ...
- MyBatis学习总结_17_Mybatis分页插件PageHelper
如果你也在用Mybatis,建议尝试该分页插件,这一定是最方便使用的分页插件. 分页插件支持任何复杂的单表.多表分页,部分特殊情况请看重要提示. 想要使用分页插件?请看如何使用分页插件. 物理分页 该 ...
- Mybatis分页插件PageHelper的配置和使用方法
Mybatis分页插件PageHelper的配置和使用方法 前言 在web开发过程中涉及到表格时,例如dataTable,就会产生分页的需求,通常我们将分页方式分为两种:前端分页和后端分页. 前端分 ...
- Mybatis分页插件PageHelper使用
一. Mybatis分页插件PageHelper使用 1.不使用插件如何分页: 使用mybatis实现: 1)接口: List<Student> selectStudent(Map< ...
- SpringBoot集成MyBatis的分页插件 PageHelper
首先说说MyBatis框架的PageHelper插件吧,它是一个非常好用的分页插件,通常我们的项目中如果集成了MyBatis的话,几乎都会用到它,因为分页的业务逻辑说复杂也不复杂,但是有插件我们何乐而 ...
- Mybatis分页插件PageHelper
application.properties配置 pagehelper.helperDialect=mysql pagehelper.reasonable=true pagehelper.suppor ...
- SpringBoot 使用 MyBatis 分页插件 PageHelper 进行分页查询
前言:本文档使用的是 SpringBoot,如果是 Spring 还需要在 MyBatis 配置 xml 中配置拦截器,并且 PageHelper 是针对 MyBatis 的,MyBatis 的集成不 ...
随机推荐
- 【Linux】自动执行Mysql常用命令脚本
wamp环境下,我可以手敲一遍,但是lamp环境下我绝对不会手敲一遍 好吧~写脚本的确也是一遍~~~~(>_<)~~~~ 函数和后面的触发器中文档上局部是有错误的,所以大家不要一味的相信文 ...
- Json Self referencing loop detected
Self referencing loop detected......的错误 解决方案: 1 增加 [JsonIgnore] 过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...
- python 模块和包
一,模块 1,什么是模块? 常见的场景: 一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py 的后缀. 但其实 import 加载的模块分为四个通用类别: 1,使用pyt ...
- MT【232】展开式中的系数
$(1+x+x^2+\cdots+x^{100})^3$展开式中$x^{150}$前的系数为_____ 解答:$(1+x+x^2+\cdots+x^{100})^3=(1-x^{101})^3\sum ...
- MT【9】绝对值二次函数
解答: 评:容易用绝对值不等式证明当$x\in[1,5]$时$|x^2+px+q|\ge2$
- WinRM不起作用 Connecting to remote server failed with the following error message : WinRM cannot complete the operation
当我运行下面的 powershell 脚本时: $FarmAcct = 'domain\user' $secPassword = ConvertTo-SecureString 'aaa' -AsP ...
- 分别用postman和python做post请求接口功能测试
前几天,在做一个post请求的接口功能测试的时候,发现数据始终无法入库, 认真加仔细检查了请求的url.方式.参数,均没有问题 找到技术确认,原来是需要传json格式数据 在头信息中加上类型,body ...
- pip常用命令、配置pip源
1.查找软件 # pip search Package 2.安装软件 # pip install Package # pip install -r requirements.txt 3.更新软件 # ...
- source insight的使用方法逆天整理
http://www.cnblogs.com/ningskyer/articles/4038501.html A. why SI: 为什么要用Source Insight呢?因为她比完整的IDE要更快 ...
- 理解for循环
先给大家出一个小题目,看看最终我们的i的值是多少? for(var i=0;i<10;i+=2){ if(i<=5){ i++; continue; }else{ i--; break; ...