How to get the data in Struts from AngularJS post

前端 未结 3 1929
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 13:42

I’m using Struts1.2 with Angular to post some data and want to get the data in java.

I’m able to retrieve the data from the server and able to display it in the scre

3条回答
  •  天涯浪人
    2020-12-15 14:20

    It is not data that you should use params instead of data tag.

    $scope.postData = function() {
    
     var data = escape(angular.toJson($scope.items));
    
     $http({
          method: 'POST',
          url: '/StrutsWithAngular/shopingCart.do',
          params: 'cartValues='+data,
          headers: {'Content-Type': 'application/x-www-form-urlencoded'}
       }).success(function(data, status, headers, config) {
            $scope.items = data;
       }).error(function(data, status, headers, config) {
        // alert("Error :: "+data);
       });
    };
    

提交回复
热议问题