这是我的.htaccess文件。
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
# Cross domain access
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, authorization"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header add Access-Control-Request-Origin "*"
Header add Access-Control-Request-Headers "origin, x-requested-with, content-type, authorization"
Header add Access-Control-Request-Methods "PUT, GET, POST, DELETE, OPTIONS"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
但是当我尝试执行PUT请求时,它会给我这样的错误。
:?!63342 / WEB-wokoshop伴侣/ index.html的_ijt = vgfnsnd7c4g6l47qh3kt00i8c8#/供应商:1 XMLHttpRequest无法加载http://abcd.com/SupplierApi/v1/supplier/5。 预检的响应具有无效的HTTP状态代码404
这是我如何从角度
提出请求function updateSupplier(supplier, id) {
var data = {
name: supplier.name,
mobile: supplier.mobile
};
var req = {
method : 'PUT',
url : REST_SERVICE_URI2 + '/' + supplier.id,
data : JSON.stringify(data),
headers : {
'Content-Type' : 'application/json'
}
};
$http(req).then(
function(response) {
alert('supplier updated.');
console.log(data);
},
function(data) {
consile.log(data);
alert('update supplier error.');
alert(data.statusText);
});
}
问题是什么?我错过了什么吗?
答案 0 :(得分:0)
尝试此删除: - $ http.delete('Url / Delete',{params:{'Id':Id}}) 试试这个更新: - $ http.put('url / Update',{params:{'Id':Id}})