Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


boostr.in questions - Question:Sending list in JSON request


I am sending few 'fields' and 'lists' in JSON to Spring MVC Controller as 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 controller 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    **listOfIds** = new ArrayList();   

//getter/setters

The issue is listOfIds is not being returned as list. It is returned as single string '350234983, 378350950'

Can anyone suggest if anything is wrong here or is there any better way to receive list in JSON response?

asked Sep 13, 2013 in Core java by anonymous
edited Sep 12, 2013
0 votes
16 views



Related Hot Questions



Government Jobs Opening


...