SpringBoot Jpa封装了分页查询
Pageable是 Spring 封装的分页实现类,使用的时候需要传入页数、每页条数和排序规则
public void testPageQuery() throws Exception {
int page=1,size=10;
Sort sort = new Sort(Direction.DESC, "id");
Pageable pageable = new PageRequest(page, size, sort);
userRepository.findALL(pageable);
}
通过这种方式分页和排序是,先查询全部然后排序再进行分页。