Search code examples
javaarrayliststruts2

Map a list of strings to an ArrayList defined in the action class - Struts2


www.abcd.com/user/getuserstats.htm?userId=123123

In this api, the userId gets set to a field named userId in the Action class mapped to this action.

Now,for this

www.abcd.com/user/getuserstats.htm?listOfUsers=123123,456456,789789,42568,58963

I need to know how can we map this list of userIds in an ArrayList defined in the corresponding Action class so that it gets mapped as an ArrayList not as a String.

Note : I don't want to get a a string of userIds and convert it to ArrayList later.I want that the list of the userIds be automatically mapped into a list or an ArrayList. I am sure there must a way to achive that.


Solution

  • basically , i found that it can be achieved like this :

    www.abcd.com/user/getuserstats.htm?userId=123123&userId=4578&userId=567&userid=987

    these params will go into an arraylist already declared in the action class.