Javascript Angular js-未添加PUT请求到服务的URL

Javascript Angular js-未添加PUT请求到服务的URL,javascript,java,html,angularjs,rest,Javascript,Java,Html,Angularjs,Rest,这是我的剧本: var shipResource = $resource('http://localhost\\:8083/consignments/:cId', null, {ship: {method: 'PUT'}}); $scope.shipConsignment = function() { if($scope.selectedConsignment != null){ var consignId = $scope.selectedConsignment.con

这是我的剧本:

var shipResource = $resource('http://localhost\\:8083/consignments/:cId', null, {ship: {method: 'PUT'}});

$scope.shipConsignment = function() {
   if($scope.selectedConsignment != null){
        var consignId = $scope.selectedConsignment.consignmentId;
        console.log(consignId) //works fine
       shipResource.ship({cId: "consignId"}); //not working? cId is not added to URL
    }
};
和HTML:

<button type="button" ng-click="shipConsignment()">Ship</button>
其中一个是服务端,我有一个函数用于对URL:localhost:8083/寄售/{commentmentid}的PUT请求

但是请求正在被发送到localhost:8083/寄售。这给我405方法不允许。任何帮助都将不胜感激。

然后尝试以下方法:

$resource('http://localhost\\:8083/consignments/:id', {Id: "@cId"}, {ship: {method: 'PUT'}});
然后试试这个:

$resource('http://localhost\\:8083/consignments/:id', {Id: "@cId"}, {ship: {method: 'PUT'}});

如果我更改方法:'GET'它会将consinId添加到url,但不用于PUT。我发现这是一个CORS问题如果我更改方法:'GET'它会将consinId添加到url,但不用于PUT。我发现这是一个CORS问题