MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法

在不使用条件查询的时候内容会完整的查询出来

pagehelper在使用的时候它首先会通过你给的条件内容先去数据库查询出来有多少条记录

MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法

然后在通过你自己写SQL语句查询分页的内容

假如我的SQL语句是:

MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法

MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法

 

注意在使用pagehelper插件的时候 不用自己去写  < LIMIT X,X>

本人的坑就踩到这里了。我自己写limit,查询出的内容一直为空。就出现了 IndexOutOfBoundsException 索引越界的错误

这是带条件的查询

MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法

同样先查询出游多少条记录 ,然后在分页查询出结果

MyBatis使用分页插件pagehelper,遇到 IndexOutOfBoundsException: Index: 0, Size: 0] with root cause解决方法