mybatis分页/分页插件

来源:互联网 发布:我是歌手网络直播地址 编辑:程序博客网 时间:2024/04/18 14:23
PageHelpler 分页插件(Mybatis 通用的第三方分页插件)

官方文档:
https://github.com/pagehelper/Mybatis-PageHelper/blob/master/README zh.md



1.引入分页插件的两种方式

    一、引入jar包
    1)jsqlparser-0.9.5.jar    2)pagehelper-5.0.0.jar
    
    二、使用Maven
    在pom.xml中添加如下依赖:
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper<artifactId>
            <version>最新版本</version>
        </dependency>
        

2.在mybatis-config.xml中配置插件,也可以在spring的xml配置文件中配置(稍微麻烦点,参考官方文档)
    <plugins>
            <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
        </plugins>

3.通过分页插件可以动态的为查询方法动态的添加limit,而且不会破坏原生的sql,支持各种数据库的
  分页。
 
4.可以使用PageInfo封装返回结果,PageInfo可以通过setNavigatePages方法设置连续显示的页码
 
 
原创粉丝点击