文章目录
1. 分页插件的配置
1.1 添加依赖
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.2.0</version>
</dependency>
1.2 配置分页插件
在MyBatis的核心配置文件(mybatis-config.xml)中配置插件
<plugins>
<!--设置分页插件-->
<plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
</plugins>
2. 分页插件的使用
2.1 开启分页功能
- 在查询功能之前使用
PageHelper.startPage(int pageNum, int pageSize)
开启分页功能 - pageNum:当前页的页码
- pageSize:每页显示的条数
@Test
public void testPageHelper() throws IOException {
InputStream is = Resources.