HttpEntity

HttpEntity 使用基于容器对象的 @RequestBody 几乎是相同的,该容器对象会公开请求标头和正文。以下示例使用 HttpEntity

HttpEntity is more or less identical to using @RequestBody but is based on a container object that exposes request headers and the body. The following example uses an HttpEntity:

  • Java

  • Kotlin

@PostMapping("/accounts")
public void handle(HttpEntity<Account> entity) {
	// ...
}
@PostMapping("/accounts")
fun handle(entity: HttpEntity<Account>) {
	// ...
}