1、pom.xml追加

pagehelper : 4.1.4

2、mappers.xml中追加

    <plugins>
<plugin interceptor="com.github.pagehelper.PageHelper">
<property name="dialect" value="mysql" />
<property name="offsetAsPageNum" value="true" />
<property name="rowBoundsWithCount" value="true" />
<property name="pageSizeZero" value="true" />
<property name="reasonable" value="false" />
<property name="returnPageInfo" value="check" />
<property name="params" value="pageNum=start;pageSize=limit;" />
</plugin>
</plugins>

3、使用

// 使用PageHelper的API,指定当前页码和每页实体个数
PageHelper.startPage(3, BasicsConstant.DEFAULT_PAGE_SIZE);
// 正常使用Mybatis,获得结果集
List<UserPo> pos = userMapper.listBy(userSex);
// 使用PageHelper的API,包装结果集
PageInfo<UserPo> userPage = new PageInfo<>(pos); int a = userPage.getPageNum();//当前页的页码 int b = userPage.getPageSize();//当前页有几条数据 int c = userPage.getTotal();//结果集中有几条数据 int d = userPage.getPages();//总共几页 boolean g = userPage.isHasPreviousPage();//当前页是否有前一页 boolean h = userPage.isHasNextPage();//当前页是否有后一页 List<UserPo> posInPage = userPage.getList();//获得应该在当前页显示的数据的List

分页——为Mybatis配置PageHelper的更多相关文章

  1. SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页

    SpringBoot+Mybatis配置Pagehelper分页插件实现自动分页 **SpringBoot+Mybatis使用Pagehelper分页插件自动分页,非常好用,不用在自己去计算和组装了. ...

  2. springboot + mybatis配置分页插件

    一:使用pagehelper配置分页插件 1:首先配置springboot +mybatis框架  参考:http://www.cnblogs.com/liyafei/p/7911549.html 2 ...

  3. springboot+mybatis使用PageHelper分页

    项目结构和spring搭建mybatis请参考springboot整合mybatis.在这个基础上配置分页. 一:导入PageHelper依赖 <dependency> <group ...

  4. 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法

    spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...

  5. Spring Boot 项目学习 (二) MySql + MyBatis 注解 + 分页控件 配置

    0 引言 本文主要在Spring Boot 基础项目的基础上,添加 Mysql .MyBatis(注解方式)与 分页控件 的配置,用于协助完成数据库操作. 1 创建数据表 这个过程就暂时省略了. 2 ...

  6. springboot结合mybatis使用pageHelper插件进行分页查询

    1.pom相关依赖引入 <dependencies> <dependency> <groupId>org.springframework.boot</grou ...

  7. Mybatis 使用PageHelper封装通用Dao分页方法

    参考: PageHelper官网:https://pagehelper.github.io/docs/howtouse/#3-%E5%A6%82%E4%BD%95%E5%9C%A8%E4%BB%A3% ...

  8. SpringBoot整合mybatis使用pageHelper插件进行分页操作

    SpringBoot整合mybatis分页操作 SpringBoot整合Mybatis进行分页操作,这里需要使用Mybatis的分页插件:pageHelper, 关于pageHelper的介绍,请查看 ...

  9. Mybatis第三方PageHelper分页插件原理

    ​ 欢迎关注公号:BiggerBoy,看更多文章 原文链接:https://mp.weixin.qq.com/s?__biz=MzUxNTQyOTIxNA==&mid=2247485158&a ...

随机推荐

  1. python几个轻量级web框架

    python几个轻量级web框架 2016-04-11 18:04:34 惹不起的程咬金 阅读数 7944更多 分类专栏: 云计算/大数据/并行计算 Python   我最近发表了一篇名为 ‘7 Mi ...

  2. java中针对 try和finally一些总结

    结论 1.不管有没有异常,finally中的代码都会执行 2.当try.catch中有return时,finally中的代码依然会继续执行 3.finally是在return后面的表达式运算之后执行的 ...

  3. (八)Activiti之流程变量和局部流程变量

    一.流程变量 1.1 概念 如果,当流程走到"学生请假"这个任务节点的时候,此时可以用TaskService设置流程变量,变量值包含请假人.请假时间.请假理由等信息,这些信息存在表 ...

  4. (三)Spring框架之事务管理

    一.编程式事务管理 Spring事务管理器的接口是org.springframework.transaction.PlatformTransactionManager,事务管理器接口PlatformT ...

  5. TCP协议和UDP协议的对比【转】

    原文:https://blog.csdn.net/lzj2504476514/article/details/81454754 一.TCP协议的主要特点(1)TCP是面向连接的运输层协议:(2)每一条 ...

  6. springboot2.0介绍1

    SpringBoot 一. Spring介绍 1.1.SpringBoot简介 在您第1次接触和学习Spring框架的时候,是否因为其繁杂的配置而退却了?在你第n次使用Spring框架的时候,是否觉得 ...

  7. 异常-ERROR yarn.ApplicationMaster: User class threw exception: java.sql.SQLException: Communications link failure

    1 详细异常信息 ERROR yarn.ApplicationMaster: User class threw exception: java.sql.SQLException: Communicat ...

  8. Ubuntu18.0 解决python虚拟环境中不同用户下或者python多版本环境中指定虚拟环境的使用问题

    一. 不同用户下配置virtualenvwrapper的问题 问题描述: 安装virtualnev和virtualnevwrapper之后,在.bashrc进行virtualenvwrapper的相关 ...

  9. How to resolve emulator cannot be launched issue by command line

    Issue: Resolution: 1. Open the system variables, find the Path and edit it, add below item : C:\User ...

  10. Java字节码常量池深入剖析

    继续来分析Java字节码,上一节分析了魔数的规则,接下来继续往下分析,其上次总结的规则也一起贴出来: 1.使用javap -verbose命令分析一个字节码文件时,将会分析该字节码文件的魔数.版本号. ...