若是你也在用Mybatis,建議嘗試該分頁插件,這必定是最方便使用的分頁插件。 html
分頁插件支持任何複雜的單表、多表分頁,部分特殊狀況請看重要提示。 mysql
想要使用分頁插件?請看如何使用分頁插件。 git
該插件目前支持如下數據庫的物理分頁: github
配置dialect屬性時,使用小寫形式: spring
oracle,mysql,mariadb,sqlite,hsqldb,postgresql,db2,sqlserver,informix sql
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.0.0</version> </dependency>
分頁插件pagehelper.jar: 數據庫
https://oss.sonatype.org/content/repositories/releases/com/github/pagehelper/pagehelper/ markdown
http://repo1.maven.org/maven2/com/github/pagehelper/pagehelper/ mybatis
因爲使用了sql解析工具,你還須要下載jsqlparser.jar(這個文件徹底獨立,不依賴其餘): oracle
配置屬性dialect不在強制要求,能夠不寫,分頁插件會自動判斷
解決從request中獲取分頁參數時的錯誤,感謝探路者☆
PageInfo增長空構造方法,全部屬性增長setter方法
增長對排序的支持
能夠單獨使用PageHelper.orderBy(String orderBy)對查詢語句增長排序,也能夠配合startPage的其餘方法使用
能夠使用PageHelper.startPage(int start,int size,String orderBy)對分頁查詢進行排序
修改分頁查詢的處理邏輯,主要是將原sqlSource包裝成能夠分頁和排序的sqlSource
若是要使用分頁插件,這篇文檔必定要看,看完確定沒有問題。
若是和Spring集成不熟悉,能夠參考下面兩個MyBatis和Spring集成的框架
只有基礎的配置信息,沒有任何現成的功能,做爲新手入門搭建框架的基礎
這兩個集成框架集成了MyBatis分頁插件和MyBatis通用Mapper。
包含所有的詳細的更新日誌。
提示很重要,建議必定看一遍!
對應於oschub的項目地址:http://git.oschina.net/free/Mybatis_PageHelper
對應於github的項目地址:https://github.com/pagehelper/Mybatis-PageHelper
Mybatis-Sample(分頁插件測試項目):http://git.oschina.net/free/Mybatis-Sample
Mybatis項目:https://github.com/mybatis/mybatis-3
Mybatis文檔:http://mybatis.github.io/mybatis-3/zh/index.html
Mybatis專欄:
做者博客:
做者郵箱: abel533@gmail.com