原文地址:https://blog.youkuaiyun.com/liuyuanjiang109/article/details/78955881
在springboot 结合mybatis 时用到pagehelper 分页工具
并进行分页、排序
其github链接如下:
https://github.com/pagehelper/Mybatis-PageHelper
https://github.com/pagehelper/pagehelper-spring-boot
pagehelper 使用简单方便 ,只需要在查询语句之前使用
PageHelper.startPage(pageNum, pageSize, orderBy)
例如:
PageHelper.startPage(1, 10, orderStandesc);
List<Course> list = courseMapper.selectCourseBySid(id);
- 1
- 2
其中orderBy参数为排序字段,如果想按照倒序或者顺序则将orserBy参数进行拼接
String orderBy = 排序字段 + " desc";//按照排序字段 倒序 排序
- 1
返回的list中就有第一页,10行数据,按照排序字段排序的 数据集合!