I am constructing the following JSON in my jQuery and sending to controller via ajax
var jsonResponse = [];
$(columns).each(function() {
if(!isEmpty($(this))) {
var lang = $(this).find(".language").val();
var item = {
"label": label,
"language": $(this).find(".language").val(),
"value": $(this).find(".value").val()
};
jsonResponse.push(item);
}
});
Since it is an array of individual items, I need to map it to an ArrayList in my controller.
My model objects are like this:
FormModel - maps to the item
JSON element
class FormModel {
String label;
String language;
String value;
// getters & setters
}
FormModelWrapper - maps to the array of items
class FormModelWrapper {
private List<FormModel> formModel;
// getters & Setters
}
Finally the controller:
@RequestMapping(value = View Name, method = RequestMethod.POST)
public String performTask( @RequestBody FormModelWrapper wrapper) {
...
}
I have Jackson configured correctly. I have actually verified it by sending a JSON item
element and accepting it in FormModel
. The 415 Error occurs when I use array of json elements.
Any help would be appreciated.