【发布时间】:2016-09-09 04:57:05
【问题描述】:
这是我的脚本:
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>
一个服务端我有一个PUT请求URL的功能:localhost:8083/consignment/{consignmentId}。
但是请求被发送到 localhost:8083/consignment。这给了我 405 方法不允许。任何帮助将不胜感激。
【问题讨论】:
-
如果我更改方法:'GET' 它会将 consinId 添加到 url 但不是 PUT。
-
我发现这是一个 CORS 问题
标签: javascript java html angularjs rest