![](/img/trans.png)
[英]How can I get a body data from the request in an ExceptionHandler in Spring Boot?
[英]Can I do a GET with request body in Spring Boot?
我正在使用 Spring Boot 和 Spring MVC,我需要使用请求正文进行 GET。 这可能吗?
我试过了,但没有用。 我得到 404。
@RestController
@RequestMapping("/api")
public class HomeController {
@GetMapping("/v1/foo")
public ApiRes postBody(@RequestBody ApiReq apiReq) {
...
}
}
从技术上讲这是可能的,但它违反了 HTTP API 设计指南。 Request-Body 应该只用于 POST 或 PUT。
更多信息: https://swagger.io/resources/articles/best-practices-in-api-design/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.