我正在使用Sping Boot 2,我在@GetMapping
中编写了一个@RestController
,它将Pageable
作为参数。
@GetMapping
public ResponseEntity<Page<AppointmentTO>> findAll(Pageable pageable) {
Page<AppointmentTO> page = appointmentService.findAll(pageable);
return ResponseEntity.ok(page);
}
字符串
问题如下:
每次请求时,queries-parameterspageSize
和offset
在到达Sping Boot Backend(?offset=0&pageSize=20
)时总是重置为默认值,但我在请求的URL中发送了不同的参数(例如?offset=15&pageSize=5
)。
2条答案
按热度按时间guicsvcw1#
Sping Boot 将请求参数Map到扩展
AbstractPageRequest
的org.springframework.data.domain.PageRequest
字符串
您应该使用以下URL:
型
你也可以添加sorting by.&sort=name
a9wyjsp72#
Sping Boot
Pageable
支持以下url参数OOTB:样本终点:
字符串
样品申请:
型
样本响应(注意下面的分页数据):
型