问题:
后台查询后的数据只有1页,已经设置了PageHelper也没用
PageHelper.startPage(pageNum,pageSize);
ModelAndView mv=new ModelAndView();
Integer count= secondService.message();
mv.addObject("count",count);
List<Second> seconds= secondService.show();
mv.addObject("seconds",seconds);
PageInfo<Second> pageInfo=new PageInfo<>(seconds);
mv.addObject("pageInfo",pageInfo);
解决方案:
PageHelper.startPage(pageNum,pageSize);只对该语句以后的第一个查询语句得到的数据进行分页。

问题解决。
PS:
pom.xml
<!--mybatis分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
mybatis-config.xml
<!--翻页插件--> <plugins> <plugin interceptor="com.github.pagehelper.PageInterceptor"> <property name="helperDialect" value="mysql"></property> <property name="reasonable" value="true"></property> </plugin> </plugins>
本文详细解析了在MyBatis中使用PageHelper分页插件时遇到的常见问题,特别是当后台查询数据仅一页时的处理方法。通过调整PageHelper的使用方式和配置,确保了数据的有效分页,适用于需要对大量数据进行高效管理和展示的场景。

2078

被折叠的 条评论
为什么被折叠?



