This is my anular js to pass json to spring controller
$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
}));
});
};
This is my spring controller:
@RequestMapping(value = "/saveCartOrder", method = RequestMethod.POST, headers = {
"Accept=*/*", "Content-Type=application/json"
})
public void saveCartOrder(@RequestBody CartBean cart) {
System.out.println(cart.getItemname());
}
I have added the jackson jar to the project: jackson-annotations-2.8.0.jar jackson-core-2.8.6.jar jackson-databind-2.8.6.jar jackson-mapper-asl-1.9.13.jar
Still iam getting this 415 Unsupported Media Type error.