On Thu, Dec 30, 2010 at 6:01 AM, Adam Walczak <me_at_adamwalczak.info> wrote:
> > @Path("/somepath/{ids}")
> > public List<Long> showList(@PathParam("ids") List<Long> ids) {
>
> I never heard of using a PathParam for a list of values. Is this this
> supported by Jersey ? what's the default separator ? or does this
> return matched values from a regexp ?
>
Thats what I want to know, if this is supported by Jersey, I can't find
anything on documentation, so I suppose it's not supported.
>
> Can't you use a 'QueryParam("id") List<Long>' ids instead ?
> The URL would look like this then: /somepath?id=1&id=2&id=2
> The above seams more HTTP natural for me.
> If this is not an option then I guess Naresh solution is the only way to
> go.
>
>
I wanted to do it as a path param as a way of having it as a mandatory
parameter. But now I'm guessing that you are right. It seems more natural to
pass the list as query params, and then have some validation. I have a new
question : When should I use query params and when path params, for me query
params come as optionals.
It seems that the only way to take a list as a path params is by taking it
as comma-sepparated string and splitting it. It is a solution but I would
like to know which of the approaches will be more restful, I guess using
query params since path param as a list is not supported.
Maybe some recursive regular expression could also do the trick? just a
> hunch.
>
> --
> Adam Walczak
> www.adamwalczak.info
> +48 604 188 992
>
--
Germán Mauricio Muñoz