As I navigate through my Angular application, I'm encountering a challenge when trying to save data on the server side using JSP. The issue arises when Angular's $save method sends the object data in a JSON format that is not familiar to me. This presents a problem as the object cannot be accessed through request.getParameter() and when examining the request in firebug, it becomes apparent that the JSON data is not sent with any parameters but rather within the "POST" part of the request. This has left me puzzled and seeking answers.
Here's what I have established so far:
The default contentType for posts in Angular is "application/json", which means changing this to "application/x-www-form-urlencoded;charset=utf-8" allows for accessing the parameters of the JSON object via request.getParameter(), provided the transmission method of the JSON object is also altered.
However,
This initial solution does not address the core issue at hand because even if I utilize jQuery.ajax() to make a request with the contentType set to "application/json" and pass the JSON object as data, I still encounter problems. While the attributes of the JSON object can be retrieved as parameters, the query string in the URL remains absent.
Therefore, my inquiries are:
1) What exactly is happening with the way Angular transmits its data?
2) Is there a feasible approach to modifying this transmission without compromising the functionality of $resource $save function (changing the contentType of $http negatively impacts $resource methods)? And more importantly,
3) If altering the transmission method is not possible (or even if it is), how can the JSON data be parsed in a JSP with the current setup?
Your assistance would be greatly appreciated as I continue to search for solutions to this perplexing dilemma that has evaded easy resolution despite my efforts thus far.