users@jersey.java.net

Re: [Jersey] Lists as QueryParams

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 27 Jan 2010 18:04:32 -0500

On Jan 27, 2010, at 5:45 PM, Dário Abdulrehman wrote:
>
> I implemented a WS that has a query parameter that can take several values so it is declared as @QueryParam ("foo") List<String> foo.
> However the list can be quite long and it is cumbersome to publish the WS like this because the user is forced to repeat the query param several times:
>
> GET ws?foo=aa&foo=bb&foo=cc ... etc
>
> I am thinking about providing a single String queryParam which will contain the list like "aa,bb,cc,...etc." which of course needs to be parsed.
> Is this a customary practice or is there an alternative solution?
>
IIRC, the way you have it now matches what a HTML form would produce. One thing to consider is whether ',' would ever legitimately appear in the value of one of your query parameters (i.e. not used as a separator) ?

Marc.