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

public @Interface RequestHeader

extends Annotation
Annotations
@Target:PARAMETER
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, org.springframework.core.annotation.AliasFor

Annotation which indicates that a method parameter should be bound to a web request header.

Supported for annotated handler methods in Spring MVC and Spring WebFlux.

If the method parameter is Map<String, String>, MultiValueMap<String, String>, or HttpHeaders then the map is populated with all header names and values.

Authors
Juergen Hoeller, Sam Brannen
Since
3.0
See Also
RequestMapping, RequestParam, CookieValue

Method Summary

Modifier and TypeMethod and Description
public String
defaultValue()

The default value to use as a fallback.

public String
name()

The name of the request header to bind to.

public boolean
required()

Whether the header is required.

public String
value()

Alias for name.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

defaultValueback to summary
public String defaultValue()

The default value to use as a fallback.

Supplying a default value implicitly sets required to false.

nameback to summary
public String name()

The name of the request header to bind to.

Annotations
@AliasFor:value
Since
4.2
requiredback to summary
public boolean required()

Whether the header is required.

Defaults to true, leading to an exception being thrown if the header is missing in the request. Switch this to false if you prefer a null value if the header is not present in the request.

Alternatively, provide a defaultValue, which implicitly sets this flag to false.

valueback to summary
public String value()

Alias for name.

Annotations
@AliasFor:name