- PaginAndSortingRespository接口包含分页和排序的功能
- 带排序的查询:findAll(Sort sort)
- 带排序的分页查询: findAll(Pageable pageable)
带排序的分页查询的示例:
Sort.Order order=new Sort.Order(Sort.Direction.DESC,"id");
Sort sort=new Sort(order);
Pageable pageable =new PageRequest(0,10,sort);
Page<Employee> page=employeePagingAndSortingRepository.findAll(pageable);
System.out.println("查询的总页数"+page.getTotalPages());
System.out.println("查询的总记录数"+page.getTotalElements());
System.out.println("查询的当前第几页"+(page.getNumber()+1));
System.out.println("查询的当前页面的集合"+page.getContent());
System.out.println("查询的当前页面的记录数"+page.getNumberOfelements());