一、@requestBody
1、使用场景:http协议为不是默认的Content-type类型(application/x-www-form-urlcoded)的请求,eg:content-type:”application/json charset=utf-8”, 或者content-type:”application/xml charset=utf-8”。
2、接收的是HttpEntity,可以接收post请求,可以接受简单类型的属性,也可以接受对象类型,GET请求中,因为没有HttpEntity,所以@RequestBody并不适用。
@RequestBody annotated parameters get linked to the HTTP request body. Parameter values are converted to the declared method argument type using HttpMessageConverters. This annotation indicates a method parameter should be bound to the body of the web request.
For example Angular request for Spring RequestBody would look like that:
$scope.user = {
username: "foo",
auth: true,
password: "bar"
};
$