users@jersey.java.net

Re: [Jersey] Sub-resource locators for _at_Path("/{x}") and _at_Path("/")?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 Oct 2009 21:55:02 +0200

Hi Chris,

It is only possible to use @Path("/") on a root resource class (which
is equivalent to @Path("")).

When we have a root resource class as follows:

   @Path("root")
   public class MyRootResource {
   }

the paths "root" and "root/" will match.

The same occurs if we have the following:

   @Path("root/")
   public class MyRootResource {
   }

Essentially in your case the fallback is the sub-resource itself.

Make sense?


Note that Jersey has an automatic redirection feature that you can
enable of @Path values end in a "/", see:

https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html
#FEATURE_REDIRECT

Paul.

On Oct 17, 2009, at 9:21 PM, Chris Hubick wrote:

> Hi.
>
> I wish to have my resource (which is itself a sub-resource) provide
> two
> separate sub-resource locators. I would like to use one sub-resource
> locator if an 'x' param is supplied in the path, else I would like to
> fallback to a "default" sub-resource locator.
>
> I annotated one locator with @Path("/{x}") and the other "default" one
> with @Path("/"), but the latter doesn't seem to work, yielding a 405
> status. If I modify the latter path to include a literal like
> @Path("/default"), it then works under that path.
>
> Is this behavior correct due to some restriction, is this a bug, or
> am I
> likely doing something wrong?
>
> Thanks!
>
> --
> Chris Hubick
> mailto:chris_at_hubick.com
> http://www.hubick.com/chris/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>