The @Path
annotation is used for the identification of the resource that is to be called for the specific request. It can be defined at the following two levels:
Class-level
API-level
Class-level @Path
annotations are termed as the root-resource classes, and the methods are defined as resource methods, whereas API-level @Path
annotations point directly to specific methods under the root-resource classes, which are defined as subresource methods. The following example shows the use of the subresources:
@Path("/userService") public class UserResource { @GET public String getUser() { return "John"; } @GET @Path("/getUserName") public String getUserName() { return "John"; } }
In this example, getUserName()
is the subresource method, as we have explicitly defined the path of the method. We can also assign regular expressions in the URI template for the root-resource class and the subresource methods. When the request URI is userService, the...