一段关于分页的代码,简单来说就是查询到相应的课程然后分页展示出来。
首先在接口的层调用时候要多加一个参数,不需要拼接到路径中,只需要在传参时候加上一个参数。
附一段核心代码
public ResponseEntity getGameMapAndCourseList(@PathVariable Long customsId, Pageable pageable) {
Page page = gameMapService.queryGameMapAndCourseList(customsId, pageable);
}
在Service层中实现接口中的方法
Page allCourseInfo = tkCourseInfoRepository.findAllByCode(code, pageable);
在dao层中直接查询出来
Page findAllByCode(StringCode, Pageable pageable);
最后在说一句就是postman最后调用的时候也是,直接拼接参数直接在后面&page=1&size=10,表示从1页开始每页10条数据。