Bean Validation specification定义:
约束注释必须定义一个有效负载元素,该元素指定与约束声明关联的有效负载。有效负载参数的类型为
Payload[]
。Class<? extends Payload>[] payload() default {};
默认值必须为空数组。
每个可附加的有效负载都扩展Payload
。/** * 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中使用此元数据?您能解释现实世界中有效载荷的其他用例吗?有效负载携带的元数据是什么?