mir eine $ http Funktion in Winkel- und einem Controller, aber die Steuerung ruf keine Daten aus Winkeln senden, in dem Protokolldruck
überspringen CORS Verarbeitung : Antwort enthält bereits "Access-Control-Allow-Origin" header
ich meine Filter in web.xml
Datei auf die Header haben
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");
meine Winkelfunktion ist diese
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);
});
}
});
und mein Controller ist dies ...
@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;
}
});
}
wenn in der Steuerung kommen, Daten der Person null ist, für den Namen und todayDate Attribute, die durch senden wird ich in eckigem.
mein Controller ist jetzt sehr einfach, weil nur die gleiche Person objet Rückkehr
Ich glaube nicht, dass es etwas zu tun hat CORS als Spring Controller ist in der Lage, die Anfrage zu empfangen, wie Sie sagen. Müssen Sie CORS für alle Hosts überhaupt aktivieren? – Matt