Annotation Interface MatrixParam
defaultValue() attribute.
Note that the @MatrixParam annotation value refers
to a name of a matrix parameter that resides in the last matched path segment
of the PathVariable-annotated Java structure that injects the value
of the matrix parameter.
The type T of the annotated parameter, field or property must either:
- Be a primitive type
- Have a constructor that accepts a single
Stringargument - Have a static method named
valueOforfromStringthat accepts a singleStringargument (see, for example,Integer.valueOf(String)) - Be
List<T>,Set<T>orSortedSet<T>, whereTsatisfies 2, 3 or 4 above. The resulting collection is read-only.
If the type is not one of the collection types listed in 5 above and the matrix parameter is represented by multiple values then the first value (lexically) of the parameter is used.
Because injection occurs at object creation time, use of this annotation on resource class fields and bean properties is only supported for the default per-request resource class lifecycle. Resource classes using other lifecycles should only use this annotation on resource method parameters.
like Framework's MatrixVariable
- 从以下版本开始:
- 4.0
- 作者:
- TODAY 2021/10/4 11:47
- 另请参阅:
-
可选元素概要
可选元素修饰符和类型可选元素说明The 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 (e.g. a matrix variable with the same name present in more than one path segment).booleanWhether the matrix variable is required.Alias forname().
-
元素详细资料
-
value
Alias forname().- 默认值:
- ""
-
name
The name of the matrix variable.- 从以下版本开始:
- 4.0
- 另请参阅:
- 默认值:
- ""
-
pathVar
String pathVarThe name of the URI path variable where the matrix variable is located, if necessary for disambiguation (e.g. a matrix variable with the same name present in more than one path segment).- 默认值:
- "\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 tofalseif you prefer anullif the variable is missing.Alternatively, provide a
defaultValue(), which implicitly sets this flag tofalse.- 默认值:
- true
-
defaultValue
String defaultValueThe default value to use as a fallback.Supplying a default value implicitly sets
required()tofalse.- 默认值:
- "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"
-