使用pagehelper操作比定义分页类要简单方便得多,这里给大家展示一下如何使用
1.在pom.xml文件中导入对应jar包
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
在mybatis的配置文件中加入
<!-- 分页插件 -->
<!-- 注意其他配置 -->
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<!--使用下面的方式配置参数,一行配置一个 -->
<value>
params=value1
<!-- 设置超出不能超出最后一页 -->
reasonable=true
</value>
</property>
</bean>
</array>
</property>