Das ist mein anular js ist json zu Feder Controller passieren415 Nicht unterstützter Medientyp mit Frühling, nachdem alle jar jackson hinzugefügt
$scope.submit = function() {
$scope.json = JSON.parse(localStorage
.getItem("itemDes"));
var jsonlen = Object.keys($scope.json).length;
for (var i = 0; i < jsonlen; i++) {
var qnty = document
.getElementById("qunty_" + i).value;
// alert(qnty);
var price = document.getElementById("subtot_" + i).value;
$scope.object2 = {
totquanty: qnty,
totprice: price
};
angular.extend($scope.json[i], $scope.object2);
}
var config = {
headers: {
'Content-Type': 'application/json;charset=utf-8;'
}
}
alert(JSON.stringify($scope.json));
//localStorage.clear();
var response = $http.post('${pageContext.request.contextPath}/saveCartOrder',
"hiii");
response.success(function(data, status, headers, config) {
alert(data);
});
response.error(function(data, status, headers, config) {
alert("Exception details: " + JSON.stringify({
data: data
}));
});
};
Diese meine Feder-Controller ist:
@RequestMapping(value = "/saveCartOrder", method = RequestMethod.POST, headers = {
"Accept=*/*", "Content-Type=application/json"
})
public void saveCartOrder(@RequestBody CartBean cart) {
System.out.println(cart.getItemname());
}
ich hinzugefügt haben, die Jackson Gefäß zum Projekt: Jackson-Annotationen-2.8.0.jar Jackson-core-2.8.6.jar Jackson-databind-2.8.6.jar Jackson-Mapper-asl-1.9.13.jar
Immer noch IAM bekommen diesen 415 nicht unterstützten Medientyp Fehler.
haben Sie diese Lösung ausprobiert? http://stackoverflow.com/a/11549679/6503002. Er legte den Accept-Header in der Anfrage – amicoderozer