分页代码详解
参考ruoyi文档:分页实现 (opens new window)
若依源码解析:pagehelper和mybaties进行分页 (opens new window)
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
/**
* 分页工具类
*
* @author ruoyi
*/
public class PageUtils extends PageHelper
{
/**
* 设置请求分页数据
*/
public static void startPage()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
Boolean reasonable = pageDomain.getReasonable();
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
}
/**
* 清理分页的线程变量
*/
public static void clearPage()
{
PageHelper.clearPage();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
page
PageDomain 分页数据
TableDataInfo 表格分页数据对象
TableSupport 表格数据处理
1
2
3
4
2
3
4
ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
# 资料
mybatis-plus分页插件-分页的total总数不对 (opens new window)
mybatis plus 很好,但是我被它坑了! (opens new window)
MyBatis-plus 插件配置有一个overflow 设置为true,默认页码溢出只会返回第一页数据
MyBatis-plus一些总结感受 (opens new window)
Mybatisplus分页插件超出范围时返回最后一页数据 (opens new window)
上次更新: 2025/04/03, 11:07:08