项目学习记录-分页插件PageHelper

匿名 (未验证) 提交于 2019-12-03 00:32:02

分页插件PageHelper

如果你也在用Mybatis,建议尝试该分页插件,这个一定是最方便使用的分页插件。
该插件目前支持Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库分页

  • 添加PageHelper 依赖到工程中

  • 在Mybatis配置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> 
  • 获取分页信息
PageHelper.startPage(1, 10); List<Country> list = countryMapper.selectAll(); //用PageInfo对结果进行包装 PageInfo page = new PageInfo(list);

PageInfo回讲数据存到Page对象中,而Page实际上是一个ArrayList。前台使用EasyUIDataGridResult 接受序列化后的page对象,然后将其反序列化为List。因此即使没有Page对象也不会报错,只是报警告。
解决警告:只需要将PageHelper依赖添加到前台即可。

六月 20, 2018 9:14:13 下午 com.alibaba.com.caucho.hessian.io.SerializerFactory getDeserializer
警告: Hessian/Burlap: ‘com.github.pagehelper.Page’ is an unknown class in WebappClassLoader
context:
delegate: false
repositories:
―――-> Parent Classloader:
ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc.Launcher$AppClassLoader@18b4aac2]
:
java.lang.ClassNotFoundException: com.github.pagehelper.Page

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