pagehelper 分页不生效,总页数总是1解决方案


问题:

  后台查询后的数据只有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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM