1.支持的數據庫
該插件目前支持Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六種數據庫分頁。
2.PageHelpper的使用
1.將pagehelpper依賴的jar包添加到工程中.
把PageHelper依賴的jar包添加到工程中。官方提供的代碼對逆向工程支持的不好,使用參考資料中的pagehelper-fix。(上傳至qq微雲)
2.在sqlMapConfig.xml中配置攔截器插件.
<plugins>
<!-- com.github.pagehelper為PageHelper類所在包名 -->
<plugin interceptor="com.github.pagehelper.PageHelper">
<!-- 設置數據庫類型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六種數據庫-->
<property name="dialect" value="mysql"/>
</plugin>
</plugins>
3.查詢,取出分頁信息.
//獲取第1頁,10條內容,默認查詢總數count
PageHelper.startPage(1, 10); List<Country> list = countryMapper.selectAll(); //用PageInfo對結果進行包裝
PageInfo page = new PageInfo(list); //測試PageInfo全部屬性 //PageInfo包含了非常全面的分頁屬性