Annotation Type Path
Paths are relative. For an annotated class the base URI is the
application path, see ApplicationPath
. For an annotated
method the base URI is the
effective URI of the containing class. For the purposes of absolutizing a
path against the base URI , a leading '/' in a path is
ignored and base URIs are treated as if they ended in '/'. E.g.:
@Path("widgets") public class WidgetsResource { @GET String getList() {...} @GET @Path("{id}") String getWidget(@PathParam("id") String id) {...} }
In the above, if the application path is
catalogue
and the application is deployed at
http://example.com/
, then GET
requests for
http://example.com/catalogue/widgets
will be handled by the
getList
method while requests for
http://example.com/catalogue/widgets/nnn
(where
nnn
is some value) will be handled by the
getWidget
method. The same would apply if the value of either
@Path
annotation started with '/'.
Classes and methods may also be annotated with Consumes
and
Produces
to filter the requests they will receive.
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueDefines a URI template for the resource class or method, must not include matrix parameters.Embedded template parameters are allowed and are of the form:
param = "{" *WSP name *WSP [ ":" *WSP regex *WSP ] "}" name = (ALPHA / DIGIT / "_")*(ALPHA / DIGIT / "." / "_" / "-" ) ; \w[\w\.-]* regex = *( nonbrace / "{" *nonbrace "}" ) ; where nonbrace is any char other than "{" and "}"
See
invalid @link
{@link <a href="http://tools.ietf.org/html/rfc5234">RFC
WSP
,ALPHA
andDIGIT
. In the abovename
is the template parameter name and the optionalregex
specifies the contents of the capturing group for the parameter. Ifregex
is not supplied then a default value of[^/]+
which terminates at a path segment boundary, is used. Matching of request URIs to URI templates is performed against encoded path values and implementations will not escape literal characters in regex automatically, therefore any literals inregex
should be escaped by the author according to the rules ofinvalid @link
{@link <a href="http://tools.ietf.org/html/rfc3986#section-3.3">RFC
regex
, incorrect use can lead to a template parameter matching unexpected URI paths. Seeinvalid @link
{@link <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">Pattern</a>
PathParam
.The literal part of the supplied value (those characters that are not part of a template parameter) is automatically percent encoded to conform to the
path
production ofinvalid @link
{@link <a href="http://tools.ietf.org/html/rfc3986#section-3.3">RFC
-