这是我的modelobject和classlevelconstraint注解
@AtLeastOneNotEmptyConstraint(fields= {"dob","age"})
public class PersonVO implements Serializable {
@NotBlank(message = "Eyes cannot not be null")
private String eyes;
@NotBlank(message = "Hair cannot not be null")
private String hair;
private String dob;
private String age;
}
@Constraint(validatedBy =AtLeastOneNotEmptyValidator.class)
@Target({ElementType.TYPE,ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface AtLeastOneNotEmptyConstraint {
String message() default "Either dob or Age is manidtory";
String[] fields();
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
有人能帮助我如何在jsp页面中显示字段级的错误消息吗<form:errors path=“age”cssclass=“error”/>。但由于它适用于两个feild,我不知道如何应用于每个字段,因为feild在绑定结果中显示为数组。
enter code here
暂无答案!
目前还没有任何答案,快来回答吧!