Search code examples
javaarraylisttype-conversionstruts2url-parameters

How to convert a comma separated list of values in URL to an ArrayList defined in the action class in Struts 2?


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 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 be a way to achive this.


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.