无法在服务器中传递对象

时间:2018-06-26 08:16:48

标签: angularjs struts2

我正在尝试将对象传递给服务器,但该对象在服务器上不接受 我的angularjs代码是

 $scope.sharePost = function () {
        console.log('Share post');
        console.log($scope.sharePostData);
        console.log($scope.sharePostData.reSentBy.id);
        $http({
            method: 'POST',
            url: "share-post",
            dataType: 'json',
            //data: {senderId: $scope.sharePostData.reSentBy.id},
              data: {pmu: $scope.sharePostData},
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(rs, status, headers, config) {
            console.log(rs);
            console.log(rs.data.st + "  " + rs.data.msg);
         }, function errorCallback(data, status, header, config) {
            alert("Opps unable to connect to server");
        }
        );

在Chrome的网络表单数据下显示

{"pmu":{"adddate":"2018-02-23T12:26:11","atomByAuthor":{"fname":"a","id":2337,"lname":"a"},"atomByReceivedBy":{"fname":"a","id":2337,"lname":"aa"},"atomBySentBy":{"fname":"a","id":2337,"lname":"a"},"id":1782,"postMessages":{"message":"hiiiiiiiiiii","messageid":1776},"reReceivedBy":{"id":"2337"},"reSentBy":{"id":"2337"},"reMessage":"sdfasdfasdfasdf","reMessageVisibility":"Private"}}

我想在服务器的pmu对象中添加此数据。

我哪里错了?

我想将整个对象发送到文件可能会变化的地方

0 个答案:

没有答案