英文:
Pagination with Criteria and PageRequest for set limit records brokes Pagination
问题
@GetMapping("/requests")
public ResponseEntity<List<Request>> getAllRequests(RequestCriteria criteria, Pageable pageable) {
log.debug("REST request to get Requests by criteria: {}", criteria);
pageable = PageRequest.of(0, recordsLimit);
Page<Request> page = requestQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
英文:
i have problem. I have method @GetMapping for gets all requests from database, but when i want to set limit of records from DB pagination stops working, where i got something wrong ? Without line pageable = PageRequest.... it works fine.
@GetMapping("/requests")
public ResponseEntity<List<Request>> getAllRequests(RequestCriteria criteria, Pageable pageable) {
log.debug("REST request to get Requests by criteria: {}", criteria);
pageable = PageRequest.of(0,recordsLimit);
Page<Request> page = requestQueryService.findByCriteria(criteria,pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
专注分享java语言的经验与见解,让所有开发者获益!
评论