[英]Can I do a GET with request body in Spring Boot?
I'm using Spring Boot and Spring MVC and I need to make a GET with a request body.我正在使用 Spring Boot 和 Spring MVC,我需要使用请求正文进行 GET。 Is this possible?这可能吗?
I tried this but it's not working.我试过了,但没有用。 I get 404.我得到 404。
@RestController
@RequestMapping("/api")
public class HomeController {
@GetMapping("/v1/foo")
public ApiRes postBody(@RequestBody ApiReq apiReq) {
...
}
}
Technically it is possible but it is against the HTTP API Design Guidelines.从技术上讲这是可能的,但它违反了 HTTP API 设计指南。 Request-Bodys should only be used for POST or PUT. Request-Body 应该只用于 POST 或 PUT。
For further information: https://swagger.io/resources/articles/best-practices-in-api-design/更多信息: https://swagger.io/resources/articles/best-practices-in-api-design/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.