下面的代码工作正常,但我不知道在发送两个数据对象的情况下如何处理请求。
//angular
$scope.data = //item object
$http({
method : 'POST',
url : '/items',
data : $scope.data,
headers : {
'Content-Type' : 'application/json'
}
}).success(function(data) {
//...
});
//java rest
@RequestMapping(value="/items", method=RequestMethod.POST)
public ResponseEntity<?> createIslem(@RequestBody Item item){
//....
}
我的 java 控制器方法签名应该如何处理下面的请求?
//angular
$scope.data = //item object
$http({
method : 'POST',
url : '/items',
//data1 is of type Item and data2 is of type AnotherObject
data : {data1: $scope.data1, data2: $scope.data2}
headers : {
'Content-Type' : 'application/json'
}
}).success(function(data) {
//...
});