Bean 验证规范定义了:
约束注释必须定义一个负载元素,该元素指定与约束声明相关联的负载。有效载荷参数的类型是
Payload[]。Run Code Online (Sandbox Code Playgroud)Class<? extends Payload>[] payload() default {};默认值必须是空数组。
每个可附加的有效载荷都扩展Payload.Run Code Online (Sandbox Code Playgroud)/** * Payload type that can be attached to a given * constraint declaration. * <p/> * Payloads are typically used to carry on metadata information * consumed by a validation client. * </p> * Use of payloads is not considered portable. */
我已经阅读了它的示例,但我不明白,例如,如何在 JSF 中使用此元数据?你能解释一下现实世界中有效载荷的其他用例吗?Payload携带的元数据是什么?