我有角和控制器的$ HTTP功能的数据,但控制器不检索数据从角发送,在日志打印
跳过CORS处理:响应已包含 “访问控制允许来源”头
我有我的configurate滤波器web.xml
文件头
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Content-Type, x-requested-with");
我的角度功能是本
app.controller('LoadCardController', function($scope, $http) {
$scope.executor = function() {
var person = {
name : 'Prueba',
todayDate : 1469679969827
};
console.log("DATA=> ", data);
$http({
method : 'POST',
url : 'http://localhost/myWeb/addPerson',
data : person,
headers : {
'Content-Type' : 'application/json'
}
}).then(function successCallback(response) {
console.log("success");
console.log(response);
}, function errorCallback(response) {
console.log("error");
console.log(response);
});
}
});
和我的控制器是这样的......
@ResponseBody
@RequestMapping(path = "/addPerson", method = RequestMethod.POST)
public Person addPerson(final Person person) throws CustomException {
person.setAge("18");
person.setBithDay("15");
LOGGER.trace("Add person with data {}", person);
return person;
}
});
}
进来控制器时,人数据为空,对于名称和属性todayDate,由发我角。
我现在控制器是非常简单的,因为只有回到同一个人OBJET
我不认为这与它有什么关系正如你所说,作为Spring控制器的CORS能够接收请求。您是否需要为所有主机启用CORS? – Matt