我通过angular $ resource发送删除任务,但它总是得到415错误,请求正文变成了字符串看起来像一个get请求。
'use strict';
(function(angular, window){
var authsys = angular.module('authsysApp');
authsys.factory('$_privilege', ['$resource', '$q', '$notify', function($resource, $q, $notify){
var resource = {
//删除权限
batchRemovePrivilege: $resource(window.ctxPath + '/rolepri/batchDeletePrivilegeFromRole', {}, {delete:{method: 'DELETE'}})
};
return {
batchRemovePrivilege: batchRemovePrivilege
};
function batchRemovePrivilege(params){
var q = resource.batchRemovePrivilege.delete(params).$promise;
return q.then(function(){
return true;
});
}
}]);
})(angular, window);
答案 0 :(得分:0)
尝试在您的请求中添加标题:
var resource = {
//删除权限
batchRemovePrivilege: function(params){
return $http({
method: 'DELETE',
url: window.ctxPath + '/rolepri/batchDeletePrivilegeFromRole',
data: params,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
}
};
<强>执行:强>
var q = resource.batchRemovePrivilege(params).$promise;