[英]Angular JS POST request not sending data
I am trying to send an JSON object to my webservice which is expecting JSON in the request data. 我正在尝试将JSON对象发送到我的Web服务,该请求在请求数据中需要JSON。 This my
POST
call from angularJS 这是我从angularJS发出的
POST
呼叫
$http({method: 'POST',
url: 'update.htm',
data: $.param($scope.cover),
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
}).success(function (data) {
// handle
});
Value for cover object 封面对象的值
$scope.cover = {id:1, bean:{id:2}}
Iam getting 500 (InvalidPropertyException: Invalid property 'bean[id]' of bean class [BookBean]: Property referenced in indexed property path 'bean[id]' is neither an array nor a List nor a Map;)
我得到
500 (InvalidPropertyException: Invalid property 'bean[id]' of bean class [BookBean]: Property referenced in indexed property path 'bean[id]' is neither an array nor a List nor a Map;)
In network, it is sending in this way 在网络中,它是以这种方式发送的
bean[id]:1
I think it should send like 我认为它应该发送像
bean.id:1
How to reslove this issue. 如何解决这个问题。 Thanks in advance
提前致谢
Looks like the data is getting to the server and is causing an error there. 看起来数据正在到达服务器,并在那里导致错误。 There's a possible duplicate question that's been answered here - Post Nested Object to Spring MVC controller using JSON
这里可能回答了一个重复的问题- 使用JSON将嵌套对象发布到Spring MVC控制器
Try posting your data like: 尝试像这样发布数据:
$http({method: 'POST',
url: 'update.htm',
data: $scope.cover,
}).success(function (data) {
// handle
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.