Jin*_*won 4 spring pagination spring-mvc spring-rest
我知道这Pageable来自spring-data-域名.
有没有直接使用任何优雅的方式org.springframework.data.domain.Pageable在@RestController?
我试过跟随.
@RequestMapping(method = RequestMethod.GET,
path = "pageable",
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Pageable> readPageable(@NotNull final Pageable pageable) {
return ResponseEntity.ok(pageable);
}
Run Code Online (Sandbox Code Playgroud)
结果不是我的预期.
...: ~ $ curl -X GET --header 'Accept: application/json' 'http://localhost:8080/.../pageable?limit=1&offset=1' | python -mjson.tool
...
{
"offset": 0,
"pageNumber": 0,
"pageSize": 20,
"sort": null
}
Run Code Online (Sandbox Code Playgroud)
Sta*_*avL 10
它应该返回不是Pageable而是Page.
public Page<YourEntityHere> readPageable(@NotNull final Pageable pageable) {
return someService.search(pageable);
}
Run Code Online (Sandbox Code Playgroud)
Pageable是请求方,包含您需要的内容.但Page包含结果.
| 归档时间: |
|
| 查看次数: |
14408 次 |
| 最近记录: |