[jax-rs-spec users] [jsr339-experts] Re: Injecting a sub-resource method path parameter into a resource field - legal or not?

From: Sergey Beryozkin <>
Date: Thu, 23 Feb 2012 11:14:16 +0000

On 23/02/12 11:01, Marek Potociar wrote:
> Hello experts,
> we've received a bug report in Jersey about the following use case:
> @Path("foo")
> public class FooResource {
> @PathParam("id") String id;
> @GET
> @Path("bar/{id}")
> public String get() {
> return id;
> }
> }
> My question is, given the "id" path template is defined on a sub-resource method, should the value still be injectable
> into the resource field or not?
Why do you refer to get() as a sub-resource method ? It's a resource
method available on the root resource; may be you meant just that :-)

Either way, I think it should work, meaning 'id' should be initialized,

@Path("bar/{id}") is for the selection algorithm to consider, while
@PathParam 'decides' where the captured 'id' should go,
the only problem is that the above only makes sense for the per-request
root resources...

> IOW, with the example above, what should be a result of GET "/foo/bar/baz" request? Should it be "baz" or null ?

Thanks, Sergey

> Thanks,
> Marek