即使我已附加我的服务响应并提供以下信息CORS 标头 :
resp.setContentType("application/json");
resp.addHeader("Access-Control-Allow-Origin", "*");
resp.addHeader("Access-Control-Allow-Credentials", "true");
resp.addHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
resp.addHeader("Access-Control-Allow-Headers", "Origin,accept,content-type");
resp.flushBuffer();
我在尝试访问某些内容时仍然在控制台中遇到以下错误POST通过我的 AngularJS 前端在服务中使用 Web 方法。
XMLHttpRequest cannot load http://192.***.*.***:8080/abc/def/search/vehicleManufacturer. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.***.*.***:8085' is therefore not allowed access.
但在同一个班级里,有些POST没有任何有效负载的方法可以完美响应。有什么建议 ?
编辑--------->
下面是我的 AngularJS 客户端屏幕代码,用于调用 Web 方法:-
getVehicleModel : function(searchData,$scope){
$http({
method:'POST',
url:'http://192.169.*.***:8085/abc/def/search/vehicleModel',
dataType:'jsonp',
data:searchData
}).
success(function(data){
console.log("vehicle model")
$scope.vehicleModel = data.Response;
});
},