users@jersey.java.net

Re: [Jersey] Jersey and arbitrary length _at_PathParams

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 12 Oct 2010 13:37:35 +0200

On Oct 11, 2010, at 6:13 PM, Ronak Patel wrote:

> Hi,
>
> I've been wondering how can I deal with arbitrary length @PathParams
> using Jersey.
>
> Specifically I have urls like:
>
> http://<host>:<port>/<context>/<resource>/<some>/<resource>/<path>/
> <of>/<arbitrary>/<length>
>
> and treat the path all as one @PathParam without resorting to using
> subresources.
>
> I know this is not really REST but would it be possible to use
> regexpressions to match all subresources with one method?
>

What do you want to match:

   <path>/<of>/<arbitrary>/<length>

or:

   <resource>/<some>/<resource>/<path>/<of>/<arbitrary>/<length>

?

You can do something like this:

   @Path("{paths: .+"}")
   @GET
   public ... get(@PathParam("paths") List<PathSegment>) {
   }

Or:

   @Path("{a}/{b}/{paths: .+"}")
   @GET
   public ... get(@PathParam("paths") List<PathSegment>) {
   }

etc...

Without a more concrete example i am not exactly sure what you want to
do,
Paul.