users@jersey.java.net

[Jersey] Re: URI for a resource

From: Rahul Babbar <rahul.babbar1_at_gmail.com>
Date: Wed, 29 Dec 2010 11:35:43 -0800

Thanks Leonardo and Adam,

I was just able to implement it using regular expressions like you suggested
and get the type using @PathParam by the following.

@Path("/foo{dot: (\\.)?}{type: ([a-zA-Z]+)?}")
public class FooRESTService {

        @GET
public void getAllFooOfType(@PathParam("type") String type) {
 logger.info(StringUtils.isBlank(type) ? "null type " : type + " type");
}
}

In the case of /foo, i get the value of type as null , and in /foo.A, i get
it as A, which is exactly what i want.

Thanks again.

Rahul


On Wed, Dec 29, 2010 at 11:09 AM, Adam Walczak <me_at_adamwalczak.info> wrote:

> I think you will have to do something like this:
>
> @Path("/")
> public class Res {
>
> @Path("foo")
> public void foo() {
> }
>
> @Path("foo.bar")
> public void fooBar() {
> }
>
> @Path("foo.alpha")
> public void fooAlpha() {
> }
>
> }
>
> or:
>
> @Path("/")
> public class Res {
>
> @Path("foo")
> public void foo() {
> }
>
> @Path("foo.{suffix}")
> public void fooWithSuffix(String suffix) {
> }
>
> }
>
> --
> Adam Walczak
> www.adamwalczak.info
> +48 604 188 992
>