设为首页 加入收藏

TOP

学习笔记——Mybatis分页插件
2023-07-25 21:42:08 】 浏览:37
Tags:习笔记 Mybatis

2023-01-13

一、Mybatis分页插件

1、使用分页插件的原因

(1)提高用户体验度

(2)降低服务器端压力

2、设计Page类

设计原则:当前页面/总页数。Eg:25/40

(1)pageNum:当前页面

(2)pages:总页数(总页数=总数据数量/每页显示数据数量)

(3)total:总数据数量

(4)pageSize:每页显示数据数量

(5)List<T>:当前页显示数据集合

3、PageHelper

(1)概述:PageHelper是Mybatis中非常方便的第三方分页插件。

(2)官方文档:

https://github.com/pagehelper/Mybatis-PageHelper/blob/master/README_zh.md

(3)PageHelper使用步骤

①导入PageHelper的相关jar包

<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.0.0</version>
</dependency>

②在mybatis-config.xml中配置分页插件

<plugins>
       <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
</plugins>

③查询之前,使用PageHelper开启分页

PageHelper.startPage(1,3);

④查询之后,可以使用更强大的PageInfo中,使用PageInfo实现后续分页效果

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇在Ubuntu上安装OpenShift并使用 下一篇学习笔记——Spring中的注解;Spr..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目