PageHelper使用

 ̄綄美尐妖づ 提交于 2020-01-08 15:48:17

之前我们整合过SSM框架,可以查询数据库数据,项目中一般不会全部查询所有数据,为了美观和性能,都是采用分页形式查询数据

一:pom.xml导入pagehelper.jar

<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper --><dependency>  <groupId>com.github.pagehelper</groupId>  <artifactId>pagehelper</artifactId>  <version>5.1.10</version></dependency>二:在 MyBatis 配置 xml 中配置拦截器插件之前我们没有单独的mybatis配置文件,都是集成在applicationContext.xml中的,现在我们需要重新创建新的mybatis配置文件

 

 

三:在applicationContext.xml中引入该文件并配置

 

 

 

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  <!-- 注意其他配置 -->
  <property name="plugins">
    <array>
      <bean class="com.github.pagehelper.PageInterceptor">
        <property name="properties">
          <!--使用下面的方式配置参数,一行配置一个 -->
          <value>
            params=value1
          </value>
        </property>
      </bean>
    </array>
  </property>
</bean>

四:在代码中使用

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!