Annotation Interface MatrixParam


Binds the value(s) of a URI matrix parameter to a resource method parameter, resource class field, or resource class bean property. Values are URL decoded A default value can be specified using the 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:

  1. Be a primitive type
  2. Have a constructor that accepts a single String argument
  3. Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String))
  4. Be List<T>, Set<T> or SortedSet<T>, where T satisfies 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).
    boolean
    Whether the matrix variable is required.
    Alias for name().
  • 元素详细资料

    • value

      @AliasFor("name") String value
      Alias for name().
      默认值:
      ""
    • name

      @AliasFor("value") String name
      The name of the matrix variable.
      从以下版本开始:
      4.0
      另请参阅:
      默认值:
      ""
    • pathVar

      String pathVar
      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).
      默认值:
      "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"
    • required

      boolean required
      Whether 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 to false if you prefer a null if the variable is missing.

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

      默认值:
      true
    • defaultValue

      String defaultValue
      The default value to use as a fallback.

      Supplying a default value implicitly sets required() to false.

      默认值:
      "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"