【发布时间】:2017-02-15 17:33:06
【问题描述】:
对端点的请求失败并出现以下错误:
400 错误请求 org.springframework.http.converter.HttpMessageNotReadableException: 缺少所需的请求正文
@GetMapping
public List<SomeObject> list(@RequestParam(required = false) String parameter, @RequestBody String body, @RequestHeader("Authorization") String token) {
.....
}
如果 @GetMapping 将更改为 @PostMapping 一切都像一个魅力。
有什么想法吗?
注意: Swagger 用于请求发送,因此错误不太可能出现在 Curl 中
更新:
因此,看起来 Spring 不支持 @RequestBody 为 @GetMapping。我还是想不通为什么? @DeleteMapping 和 @RequestBody 工作正常,根据 HTTP/1.1 GET 请求可能包含正文 - stackoverflow.com/questions/978061/http-get-with-request-body
IMO 允许 DELETE 中的 body 但禁止 GET 中看起来有点不一致
【问题讨论】:
标签: spring http swagger spring-restcontroller