@NotEmpty
private String cname;
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
private String cdescription;
public String getCdescription() {
return cdescription;
}
public setCdescription(String cdescription) {
if(cdescription.length()>0){
this.cdescription = cdescription;}
在上面的代码中,Cname 是必填字段,Cdescription 是非必填字段,但必须进行验证。Cname 工作正常。我想知道如何在不强制要求的情况下验证 Cdescription