系列目录
步骤1:添加POM依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.3</version>
</dependency>
步骤2:在MyBatis的xml配置文件中注册拦截器
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
</plugins>
注意:中间的PageInterceptor不要写错,否者会出现PageHelper未注册的情况
步骤3:在需要分页的内容的Dao层方法调用之前添加PageHelper的方法
//参数填写如下
PageHelper.startPage(第n页,每页显示m条);
//调用Dao方法之前添加,不要放错位置,否者不起效果!
List<Course> page = courseDao.findByPage(queryPageBean);
使用效果: