我有以下从 jsp 表单提交的 bean 类。我需要在保存到数据库之前对其进行验证。但我想忽略表单验证中的集合字段,因为它总是从表单返回 null。我可以完全删除该字段,但我将同一个 bean 类用于我需要在此 bean 中收集的其他场景。那么是否有任何注释或方法可以忽略集合字段的验证?
@Setter
@Getter
public class ProvGroup {
private long provGrpId;
@NotNull(message = "This field is required.")
@NotEmpty(message = "This field is required.")
@NotBlank(message = "This field is required.")
private String provGrpName;
private String description;
@NotNull(message = "This field is required.")
@NotEmpty(message = "Add at least one provider to table.")
private String provGrpProvs;
private List<Provider> providers; <--- I need to ignore this from validation
}