PageHelper使用方法

下面有两种配置方式,选择其中一种就行

(1)、application.properties

#下面两行正常写法
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
#如果启用supportMethodsArguments参数,则pageHelper可以自动拦截请求参数中的pageNum,pageSize参数
#不启用supportMethodsArguments参数,则需使用PageHelper.startPage(pageNum,pageSize)方法调用 
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

(2)、mybatis-config.xml

<plugins>
   <!-- com.github.pagehelper为PageHelper类所在包名 -->
   <plugin interceptor="com.github.pagehelper.PageInterceptor">
      <!-- 使用下面的方式配置参数,后面会有所有的参数介绍 -->
      <property name="helperDialect" value="mysql"/>
      <property name="reasonable" value="true"/>
      <property name="supportMethodsArguments" value="true"/>
      <property name="params" value="count=countSql"/>
   </plugin>
</plugins>

猜你喜欢

转载自my.oschina.net/u/3277156/blog/1802174