2014-03-14 152 views
1

我想發送一個JSON對象到我的web服務,它在請求數據中期待JSON。 這是我POST呼叫從angularJSAngular JS 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 
    }); 

價值覆蓋對象

$scope.cover = {id:1, bean:{id:2}} 

蔭越來越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;)
在網絡上,我們以這種方式發送

bean[id]:1 

我認爲它應該像

發送
bean.id:1 

如何解決此問題。在此先感謝

+0

爲什麼要使用$ .PARAM如果你要發送的JSON數據? – BKM

回答

0

嘗試張貼您的數據,如:

$http({method: 'POST', 
     url: 'update.htm', 
     data: $scope.cover, 
    }).success(function (data) { 
    // handle 
    }); 
+0

在服務器端,我得到了空值 – vivek