2016-06-07 4 views
0

나는 나머지 webservice를 썼고 다음과 같은 java 코드를 가지고있는 오류를 피했다. 등록 된 메시지 본문 판독기가 MIME 미디어 유형과 호환되며 내 $ http.post에 'Content-Type' : 'application/x-www-form-urlencoded'또는 'Content-Type': 'application/json'. Angularjs 1.3.5를 사용 중이고 헤더 {content-type ....}을 추가하려고 할 때마다 실패했습니다. 내 문제를 해결하기 위해 정확히 무엇을 할 수 있습니까? 이 일

$scope.save = function(url,data) { 
 
    var data_stack = $scope.stack; 
 
\t \t $http.post(url, data_stack) 
 
      .then(
 
      function(response){ 
 
       }, 
 
      function(response){ 
 
       }); 
 
}
<form ng-submit="save()"> 
 
     <input ng-model="stack"></input> 
 
     <button type="submit">Save</button> 
 
</form>

답변

3
var req = { 
method: 'POST', 
url: 'http://example.com', 
headers: { 
    'Content-Type':'application/x-www-form-urlencoded' 
    // or 'Content-Type':'application/json' 
}, 
data: { test: 'test' } 
} 

$http(req).then(function(){...}, function(){...}); 
+0

, 감사합니다! –

+0

그것은 나의 기쁨 :) –

관련 문제