HttpEntity
HttpEntity
与使用@RequestBody
大致相同,但它基于一个容器对象,该对象公开请求头和正文。以下清单显示了一个示例
-
Java
-
Kotlin
@PostMapping("/accounts")
public void handle(HttpEntity<Account> entity) {
// ...
}
@PostMapping("/accounts")
fun handle(entity: HttpEntity<Account>) {
// ...
}