Skip to content
Mihail Kuznetsov edited this page Mar 13, 2015 · 2 revisions

Resource locators

Resource locators

One more type of JAX-RS methods are methods that have @Path annotation but do not have HTTP method annotation. Such methods called sub-resource locators and can’t process request directly but they can produce Java object. This object must have resource methods with required HTTP method annotations and (optionally) @Path. Note: Resource locators MAY NOT have not annotated parameters since locators may not read request body.

@Path("root")
public class MyResource
{
   @Path("resource")
   public MySubResource get()
   {
      return new MySubResource();
   }

   public static class MySubResource
   {
      @GET
      public String doGet()
      {
         return "Hello from Sub-Resource.";
      }
   }
}