用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
## 概述 `PageHelper` 就是 `mybatis` 拦截器的一个应用,实现分页查询,支持常见的 12 种数据库的物理分页并支持多种分页方式。 - 官网: https://pagehelper.github.io/ ## 安装 > pom.xml ```xml <!-- PageHelper 分页 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.4</version> </dependency> ``` > application.yaml ```yml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=cou ntSql ``` > classpath:mybatis/mybatis-config.xml mybatis 配置文件 ```xml <plugins> <!-- com.github.pagehelper 为 PageHelper 类所在包名 --> <plugin interceptor="com.github.pagehelper.PageHelper"> <!-- 目前支持的数据库类型有 Oracle, Mysql, MariaDB, SQLite, Hsqldb, PostgreSQL 六种数据库--> <property name="dialect" value="mysql"/> </plugin> </plugins> ``` ## 如何使用 ```java @GetMapping(path = "list") public JsonResult list() { PageHelper.startPage(1, 1); // 页码, 分页大小, 是否count List<SysUser> list = s.getList(); PageInfo<SysUser> sysUserPageInfo = new PageInfo<>(list); return new JsonResult(sysUserPageInfo.getList()); // sysUserPageInfo.getTotal() 获取总数 } ``` 更多使用方式 请查阅官网文档