@Target(value=PARAMETER) @Retention(value=RUNTIME) @Documented public @interface RequestHeader
If the method parameter is Map<String, String>
or
MultiValueMap<String, String>
,
or HttpHeaders
then the map is
populated with all header names and values.
RequestMapping
,
RequestParam
,
CookieValue
,
RequestMappingHandlerAdapter
,
AnnotationMethodHandlerAdapter
Modifier and Type | Optional Element and Description |
---|---|
String |
defaultValue
The default value to use as a fallback.
|
boolean |
required
Whether the header is required.
|
String |
value
The name of the request header to bind to.
|
public abstract String value
public abstract boolean required
Default is true
, leading to an exception thrown in case
of the header missing in the request. Switch this to false
if you prefer a null
in case of the header missing.
Alternatively, provide a defaultValue()
, which implicitly sets
this flag to false
.
public abstract String defaultValue
required()
to false
.