users@jersey.java.net

matching exact number of path segments

From: Louis Polycarpou <Louis.Polycarpou_at_Sun.COM>
Date: Tue, 04 Aug 2009 18:12:11 +0100

In order to process a pathparam that always contains a "/" (not
encoded), I'm trying to match on an exact number of pathsegments, and
have Jersey map this for me ideally to a String. Is there a regexp
that will work for this - I tried a few things, but couldn't quite
figure it out...

Example:

A field mediatype is always of the form "media/type"

     @GET("{media}/{type}")
     @Produces("text/plain")
     public Response getMedia(@PathParam ("{media}") String media,
@PathParam ("{type}") String type ) {
         // now rebuild the String
        String mediatype = media + "/" + type;

        ...
     }
The above will work but is there a way to do this with regexp in
Jersey so that it parses the "/" into a single String for me?

Thanks,
Louis