I have the following JSON
["2848","241"]
By using following jquery code
var list = [];
$.each($("input[class='selected']:checked"), function(){
list.push($(this).val());
});
I am sending this data to my spring controller by using following in ajax post request.
var jsonData = JSON.stringify(list);
My spring controller is as follows
@RequestMapping(value="/myurl", method = RequestMethod.POST)
public String sampleMethod(@RequestBody String jsonData){
Type dataType = new TypeToken<List<String>>(){}.getType();
List<String> myListObject = gson.fromJson(jsonData, dataType);
System.out.println(myListObject.size());
return "redirect:/someotherurl";
}
I get 500 internal server error for some reason but no stack trace or errors on my console in browser. Please suggest what is missing.?
sampleMethodcode until you find the error.fromJsonvalid and what you'd expect them to be? This method could throw aJsonParseExceptionor aJsonSyntaxException.