users@jersey.java.net

Re: [Jersey] Binding resource to base uri

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 09 Mar 2009 16:32:01 +0100

On Mar 5, 2009, at 4:35 PM, Саид Асадуллин wrote:

> Hello!
> I`m new in RS. I`ve started with jersey and got a little problem: I
> mapped jersey servlet to "resource/*" and created resources with
> @Path("/") and @Path("{project}/"). When I'm trying to GET
> "http://localhost/resource/" it returns the "{project}/" resource, not
> "/". The uriInfo.getPathParameters().getFirst("project") returns
> "resource"...

> Is it possible to bind resource to "/"?
>

Yes, what version of Jersey are you using? and what Web container are
you using?

Jersey can support:

   @Path("/") public class Slash { ... }

   @Path("/{projects}") public class Projects { ... }


So that

   http://localhost/webapp/resource/

maps to the root resource Slash. And,

   http://localhost/webapp/resource/1234

maps to the root resource Projects.


However as Naresh and I observe:

   http://localhost/webapp/resource

maps to the root resource Projects. Which is definitely a bug,
possibly in servlet as the URI pattern "resources/*" does not match.
Naresh could you log an issue with Jersey so we do not forget to
investigate further?

Paul.