Mybatis分页插件的使用
1.导入依赖
<dependency> <groupId>com.github.pagehelper
groupId> <artifactId>pagehelper
artifactId> <version>5.2.0
version>
dependency>
2.在mybatis的核心配置文件中配置插件
<plugins> <plugin interceptor="com.github.pagehelper.PageInterceptor">
plugin>
plugins>
3.在查询功能前加上开启分页
Page
4.在查询之后获取分页具体信息,使用pageinfo对象
Page<Object> objects = PageHelper.startPage(1, 2); List<Student> students = mapper.selectByExample(null); PageInfo<Student> studentPageInfo = new PageInfo<>(students, 5);//第一个参数是刚查询的数据,第二个参数是显示导航页码显示几个
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/178331.html原文链接:https://javaforall.net
