users@jersey.java.net

[Jersey] Re: Need help with path mapping

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 15 Dec 2010 12:04:51 +0100

Hi,

I am guessing here because your requirements are not precisely
defined :-)

One way you can do this with @Path is to have some literal characters
that distinguish between services and anything else. For example:

   @Path("svcs/{services}/{service}")
   public class A {}

   @Path("/") // or @Path("{anything-else: .+}
   public class B {}


If the mapping to B is guaranteed to be just one path segment and the
mapping to A is guaranteed to be two or more path segments then you
can do this:

   @Path("{services}/{service}")
   public class A {}

   @Path("{something-else}")
   public class B {}


If the set of characters in {services} and {something-else} is
distinct then you can utilize a regular expression.

Paul.

On Dec 15, 2010, at 3:02 AM, tmp wrote:

>
> hello!
>
> I want to achieve the following mapping:
>
> "localhost:8080/myapp/services/serviceA1" -> class A
> "localhost:8080/myapp/services/serviceA2" -> class A
> "localhost:8080/myapp/*" -> class B
>
> "*" means that
> "localhost:8080/myapp/xyz" is mapped to class B, as well as
> "localhost:8080/myapp/xyz/abc" or
> "localhost:8080/myapp/xyz/abc/123" and so on
>
> I'm using tomcat and already tried to achieve this by adding filter-
> mappings
> in the web.xml - with no luck.
> So at the moment I'm forwarding every request to the jersey
> ServletContainer. But I cannot find any solution with the path
> annotations.
>
> Do you have any ideas?
> Thank you very much
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Need-help-with-path-mapping-tp5835208p5835208.html
> Sent from the Jersey mailing list archive at Nabble.com.