Top Description Methods
org.springframework.web.service.annotation

public @Interface HttpExchange

extends Annotation
Annotations
@Target:TYPE, METHOD
@Retention:RUNTIME
@Documented
@Mapping
@Reflective:HttpExchangeReflectiveProcessor
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, org.springframework.aot.hint.annotation.Reflective, org.springframework.core.annotation.AliasFor, org.springframework.http.HttpEntity, org.springframework.web.bind.annotation.Mapping, org.springframework.web.util.UriBuilderFactory

Annotation to declare a method on an HTTP service interface as an HTTP endpoint. Endpoint details are defined statically through attributes of the annotation, as well as through the input method argument types.

An HTTP service interface can be passed to org.springframework.web.service.invoker.HttpServiceProxyFactory to create a client proxy. It can also be implemented by an @Controller for server handling. For more details in comparison to @RequestMapping, see the reference docs.

Supported at the type level to express common attributes, to be inherited by all methods, such as a base URL path. At the method level, it's more common to use one of the following HTTP method specific, shortcut annotations, each of which is itself meta-annotated with HttpExchange:

Supported method arguments:

Method Argument Description Resolver
URI Dynamically set the URL for the request, overriding the annotation's url() attribute org.springframework.web.service.invoker.UrlArgumentResolver
UriBuilderFactory Dynamically set the base URI for the request, overriding the one from the annotation's url() attribute, while keeping the subsequent path segments as defined there org.springframework.web.service.invoker.UriBuilderFactoryArgumentResolver
HttpMethod Dynamically set the HTTP method for the request, overriding the annotation's method() attribute HttpMethodArgumentResolver
@RequestHeader Add a request header RequestHeaderArgumentResolver
@PathVariable Add a path variable for the URI template PathVariableArgumentResolver
@RequestBody Set the body of the request RequestBodyArgumentResolver
@RequestParam Add a request parameter, either form data if "Content-Type" is "application/x-www-form-urlencoded" or query params otherwise RequestParamArgumentResolver
@RequestPart Add a request part, which may be a String (form field), org.springframework.core.io.Resource (file part), Object (entity to be encoded, e.g. as JSON), HttpEntity (part content and headers), a org.springframework.http.codec.multipart.Part, or a org.reactivestreams.Publisher of any of the above. ( RequestPartArgumentResolver
@CookieValue Add a cookie CookieValueArgumentResolver
Author
Rossen Stoyanchev
Since
6.0

Method Summary

Modifier and TypeMethod and Description
public String[]
accept()

The media types for the "Accept" header.

public String
contentType()

The media type for the "Content-Type" header.

public String
method()

The HTTP method to use.

public String
url()

The URL for the request, either a full URL or a path only that is relative to a URL declared in a type-level @HttpExchange, and/or a globally configured base URL.

public String
value()

This is an alias for url.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

acceptback to summary
public String[] accept()

The media types for the "Accept" header.

Supported at the type level as well as at the method level, in which case the method-level values override type-level values.

By default, this is empty.

contentTypeback to summary
public String contentType()

The media type for the "Content-Type" header.

Supported at the type level as well as at the method level, in which case the method-level values override type-level values.

By default, this is empty.

methodback to summary
public String method()

The HTTP method to use.

Supported at the type level as well as at the method level. When used at the type level, all method-level mappings inherit this value.

By default, this is empty.

urlback to summary
public String url()

The URL for the request, either a full URL or a path only that is relative to a URL declared in a type-level @HttpExchange, and/or a globally configured base URL.

By default, this is empty.

Annotations
@AliasFor:value
valueback to summary
public String value()

This is an alias for url.

Annotations
@AliasFor:url