Annotation Interface MatrixVariable
Annotation which indicates that a method parameter should be bound to a
name-value pair within a path segment. Supported for
RequestMapping
annotated handler methods.
If the method parameter type is Map
and a matrix variable
name is specified, then the matrix variable value is converted to a
Map
assuming an appropriate conversion strategy is available.
If the method parameter is Map<String, String>
or
MultiValueMap<String, String>
and a variable name is not specified, then the map is populated with all
matrix variable names and values.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe default value to use as a fallback.The name of the matrix variable.The name of the URI path variable where the matrix variable is located, if necessary for disambiguation (for example, a matrix variable with the same name present in more than one path segment).boolean
Whether the matrix variable is required.Alias forname()
.
-
Element Details
-
value
Alias forname()
.- Default:
- ""
-
name
The name of the matrix variable.- Since:
- 4.2
- See Also:
- Default:
- ""
-
pathVar
String pathVarThe name of the URI path variable where the matrix variable is located, if necessary for disambiguation (for example, a matrix variable with the same name present in more than one path segment).- Default:
- "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"
-
required
boolean requiredWhether the matrix variable is required.Default is
true
, leading to an exception being thrown in case the variable is missing in the request. Switch this tofalse
if you prefer anull
if the variable is missing.Alternatively, provide a
defaultValue()
, which implicitly sets this flag tofalse
.- Default:
- true
-
defaultValue
String defaultValueThe default value to use as a fallback.Supplying a default value implicitly sets
required()
tofalse
.- Default:
- "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"
-