I am sending a few “fields” and “lists” to JSON in Spring MVC Controller, as shown below:
var data = {
'message' : 'Text data',
'**listOfIds**' : '350234983, 378350950',
'synchronizerToken' : formTokenId
};
$.ajax({
url : 'testURL.do',
type : 'post',
data : data,
cache : false,
dataType : 'json',
success : function (jsonResponse) {},
error : function (error) {}
});
In Spring MVC, the URL handler looks like this:
@RequestMapping(value = "/testURL.do", method = RequestMethod.POST)
public ModelAndView executeTest( ListData listData) {
ModelAndView modelAndView = null;
JsonResponse jsonResponse = null;
modelAndView = executeTransaction(listData);
}
return modelAndView;
}
ListData.java
public class ListData{
private String message;
private List<String> **listOfIds** = new ArrayList<String>();
Problem listOfIds is not returned as a list. It is returned as a single line '350234983, 378350950
Can anyone suggest if something is wrong, or is there a better way to get a list in a JSON response?
Thanks, -Fonda
source
share