-
@Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Documented public @interface Path
Identifies the URI path that a resource class or class method will serve requests for.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 athttp://example.com/
, thenGET
requests forhttp://example.com/catalogue/widgets
will be handled by thegetList
method while requests forhttp://example.com/catalogue/widgets/nnn
(wherennn
is some value) will be handled by thegetWidget
method. The same would apply if the value of either@Path
annotation started with '/'.Classes and methods may also be annotated with
Consumes
andProduces
to filter the requests they will receive.
-
-
Element Detail
-
value
public abstract String value
Defines 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 RFC 5234 for a description of the syntax used above and the expansions of
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 of RFC 3986 section 3.3. Caution is recommended in the use ofregex
, incorrect use can lead to a template parameter matching unexpected URI paths. See Pattern for further information on the syntax of regular expressions. Values of template parameters may be extracted usingPathParam
.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 of RFC 3986 section 3.3. Note that percent encoded values are allowed in the literal part of the value, an implementation will recognize such values and will not double encode the '%' character.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/ws/rs/Path.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.