Spring的分页类在spring-data-commons包里。
Pageable: Abstract interface for pagination information. 分页信息的抽象。 PageRequest: Basic Java Bean implementation of Pageable. 对Pageable的基本实现。 属性page 页码,以0开始计数为首页,非负, 属性size 一页的大小,大于0, 属性Sort 排序。
常用方法:Pageable: next()下一页,previousOrFirst()前一页。 PageRequest: of(page,size,sort)
Page: A page is a sublist of a list of objects. It allows gain information about the position of it in the containing entire list. 列表的子集,包含了位置信息。 PageImpl: Page的基本实现。 Page、PageImpl中都会用到Pageable
默认的分页注解
@GetMapping("/user") public List<User> query(@PageableDefault(page=2,size=17,sort="username,asc")Pageable pageable){//用spring自带的pageable对象来得到分页信息