![](/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.