在 SpringBoot 应用程序上,有一个 @RestController,它包含以下 api:
@GetMapping("/api")
public SomeDto getMyApi(@RequestParam UUID userId, Pageable pageable) {
return testService.getMyApi(pageable,userId);
}
从 Javascript 客户端应用程序或 Swagger 调用 api 时,Pageable 对象始终使用默认值(页面:0,大小:21)实例化。 即使使用 Swagger 生成的以下请求进行调用:
.../api?offset=0&pageNumber=3&pageSize=100&userId=2d02a66e-d7b1-49b3-9fe2-5ec4ff3abffc
这里做错了什么?
Swagger 没有为您生成正确的参数。检查 Spring Data 的 this 文档以获取正确的参数名称。如果您将 Springfox 用于 Swagger,在撰写此答案时参数名称问题是一个 open issue.