分页插件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对象中