我有一个Employee类,它以PersonalDetails类对象作为成员
public class Employee {
private long empId;
private PersonalDetails personalDetails = new PersonalDetails();
// getters setters
PersonalDetails
类如下所示
/**
* Class represents personal details of an employee
*
* <BR>
* <BR>
* <B>Supported API: </B>false <BR>
* <BR>
* <B>Extendable: </B>false
*/
public class PersonalDetails {
private String empfirstName, empMiddleName, empLastName, gender, birthPlace, marritalStatus,
longMedicalTreatmentDescription, suffix, ethnicity, veteranStatus, prefFirstName, preLastName, birthCountry,
citizenship, citizenshipCountry1, citizenshipCountry2, visaType, email;
private Address permanentAddress, presentAddress;
private OtherContactDetails emergencyContactDetails;
private Date dob, visaExp;
private int age, noOfChildrens, healthVision;
private Boolean hasPhysicalDisability, hadLongMedicalTreatment, hasFourWheelLiscence, isPresentAddressSame;
private Passport passportDetails;
private FatherOrHusband fatherOrHusbandDetails;
/**
* @return the empfirstName
*/
public String getEmpfirstName() {
return empfirstName;
}
/**
* @param empfirstName
* the empfirstName to set
*/
public void setEmpfirstName(String empfirstName) {
this.empfirstName = empfirstName;
}
/**
* @return the empMiddleName
*/
public String getEmpMiddleName() {
return empMiddleName;
}
/**
* @param empMiddleName
* the empMiddleName to set
*/
public void setEmpMiddleName(String empMiddleName) {
this.empMiddleName = empMiddleName;
}
/**
* @return the empLastName
*/
public String getEmpLastName() {
return empLastName;
}
/**
* @param empLastName
* the empLastName to set
*/
public void setEmpLastName(String empLastName) {
this.empLastName = empLastName;
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @param gender
* the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
/**
* @return the birthPlace
*/
public String getBirthPlace() {
return birthPlace;
}
/**
* @param birthPlace
* the birthPlace to set
*/
public void setBirthPlace(String birthPlace) {
this.birthPlace = birthPlace;
}
/**
* @return the marritalStatus
*/
public String getMarritalStatus() {
return marritalStatus;
}
/**
* @param marritalStatus
* the marritalStatus to set
*/
public void setMarritalStatus(String marritalStatus) {
this.marritalStatus = marritalStatus;
}
/**
* @return the longMedicalTreatmentDescription
*/
public String getLongMedicalTreatmentDescription() {
return longMedicalTreatmentDescription;
}
/**
* @param longMedicalTreatmentDescription
* the longMedicalTreatmentDescription to set
*/
public void setLongMedicalTreatmentDescription(String longMedicalTreatmentDescription) {
this.longMedicalTreatmentDescription = longMedicalTreatmentDescription;
}
/**
* @return the permanentAddress
*/
public Address getPermanentAddress() {
return permanentAddress;
}
/**
* @param permanentAddress
* the permanentAddress to set
*/
public void setPermanentAddress(Address permanentAddress) {
this.permanentAddress = permanentAddress;
}
/**
* @return the presentAddress
*/
public Address getPresentAddress() {
return presentAddress;
}
/**
* @param presentAddress
* the presentAddress to set
*/
public void setPresentAddress(Address presentAddress) {
this.presentAddress = presentAddress;
}
/**
* @return the dob
*/
public Date getDob() {
return dob;
}
/**
* @param dob
* the dob to set
*/
public void setDob(Date dob) {
this.dob = dob;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @param age
* the age to set
*/
public void setAge(int age) {
this.age = age;
}
/**
* @return the noOfChildrens
*/
public int getNoOfChildrens() {
return noOfChildrens;
}
/**
* @param noOfChildrens
* the noOfChildrens to set
*/
public void setNoOfChildrens(int noOfChildrens) {
this.noOfChildrens = noOfChildrens;
}
/**
* @return the healthVision
*/
public int getHealthVision() {
return healthVision;
}
/**
* @param healthVision
* the healthVision to set
*/
public void setHealthVision(int healthVision) {
this.healthVision = healthVision;
}
/**
* @return the passportDetails
*/
public Passport getPassportDetails() {
return passportDetails;
}
/**
* @param passportDetails
* the passportDetails to set
*/
public void setPassportDetails(Passport passportDetails) {
this.passportDetails = passportDetails;
}
/**
* @return the suffix
*/
public String getSuffix() {
return suffix;
}
/**
* @param suffix
* the suffix to set
*/
public void setSuffix(String suffix) {
this.suffix = suffix;
}
/**
* @return the fatherOrHusbandDetails
*/
public FatherOrHusband getFatherOrHusbandDetails() {
return fatherOrHusbandDetails;
}
/**
* @param fatherOrHusbandDetails
* the fatherOrHusbandDetails to set
*/
public void setFatherOrHusbandDetails(FatherOrHusband fatherOrHusbandDetails) {
this.fatherOrHusbandDetails = fatherOrHusbandDetails;
}
/**
* @return the hasPhysicalDisability
*/
public Boolean isHasPhysicalDisability() {
return hasPhysicalDisability;
}
/**
* @param hasPhysicalDisability
* the hasPhysicalDisability to set
*/
public void setHasPhysicalDisability(Boolean hasPhysicalDisability) {
this.hasPhysicalDisability = hasPhysicalDisability;
}
/**
* @return the hadLongMedicalTreatment
*/
public Boolean isHadLongMedicalTreatment() {
return hadLongMedicalTreatment;
}
/**
* @param hadLongMedicalTreatment
* the hadLongMedicalTreatment to set
*/
public void setHadLongMedicalTreatment(Boolean hadLongMedicalTreatment) {
this.hadLongMedicalTreatment = hadLongMedicalTreatment;
}
/**
* @return the hasFourWheelLiscence
*/
public Boolean isHasFourWheelLiscence() {
return hasFourWheelLiscence;
}
/**
* @param hasFourWheelLiscence
* the hasFourWheelLiscence to set
*/
public void setHasFourWheelLiscence(Boolean hasFourWheelLiscence) {
this.hasFourWheelLiscence = hasFourWheelLiscence;
}
/**
* @return the isPresentAddressSame
*/
public Boolean isPresentAddressSame() {
return isPresentAddressSame;
}
/**
* @param isPresentAddressSame
* the isPresentAddressSame to set
*/
public void setPresentAddressSame(Boolean isPresentAddressSame) {
if (isPresentAddressSame) {
presentAddress = permanentAddress;
}
this.isPresentAddressSame = isPresentAddressSame;
}
/**
* @return the ethnicity
*/
public String getEthnicity() {
return ethnicity;
}
/**
* @param ethnicity
* the ethnicity to set
*/
public void setEthnicity(String ethnicity) {
this.ethnicity = ethnicity;
}
/**
* @return the veteranStatus
*/
public String getVeteranStatus() {
return veteranStatus;
}
/**
* @param veteranStatus
* the veteranStatus to set
*/
public void setVeteranStatus(String veteranStatus) {
this.veteranStatus = veteranStatus;
}
/**
* @return the prefFirstName
*/
public String getPrefFirstName() {
return prefFirstName;
}
/**
* @param prefFirstName
* the prefFirstName to set
*/
public void setPrefFirstName(String prefFirstName) {
this.prefFirstName = prefFirstName;
}
/**
* @return the preLastName
*/
public String getPreLastName() {
return preLastName;
}
/**
* @param preLastName
* the preLastName to set
*/
public void setPreLastName(String preLastName) {
this.preLastName = preLastName;
}
/**
* @return the birthCountry
*/
public String getBirthCountry() {
return birthCountry;
}
/**
* @param birthCountry
* the birthCountry to set
*/
public void setBirthCountry(String birthCountry) {
this.birthCountry = birthCountry;
}
/**
* @return the citizenship
*/
public String getCitizenship() {
return citizenship;
}
/**
* @param citizenship
* the citizenship to set
*/
public void setCitizenship(String citizenship) {
this.citizenship = citizenship;
}
/**
* @return the citizenshipCountry1
*/
public String getCitizenshipCountry1() {
return citizenshipCountry1;
}
/**
* @param citizenshipCountry1
* the citizenshipCountry1 to set
*/
public void setCitizenshipCountry1(String citizenshipCountry1) {
this.citizenshipCountry1 = citizenshipCountry1;
}
/**
* @return the citizenshipCountry2
*/
public String getCitizenshipCountry2() {
return citizenshipCountry2;
}
/**
* @param citizenshipCountry2
* the citizenshipCountry2 to set
*/
public void setCitizenshipCountry2(String citizenshipCountry2) {
this.citizenshipCountry2 = citizenshipCountry2;
}
/**
* @return the visaType
*/
public String getVisaType() {
return visaType;
}
/**
* @param visaType
* the visaType to set
*/
public void setVisaType(String visaType) {
this.visaType = visaType;
}
/**
* @return the emergencyContactDetails
*/
public OtherContactDetails getEmergencyContactDetails() {
return emergencyContactDetails;
}
/**
* @param emergencyContactDetails
* the emergencyContactDetails to set
*/
public void setEmergencyContactDetails(OtherContactDetails emergencyContactDetails) {
this.emergencyContactDetails = emergencyContactDetails;
}
/**
* @return the visaExp
*/
public Date getVisaExp() {
return visaExp;
}
/**
* @param visaExp
* the visaExp to set
*/
public void setVisaExp(Date visaExp) {
this.visaExp = visaExp;
}
/**
* @return the email
*/
public String getEmail() {
return email;
}
/**
* @param email
* the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "PersonalDetails [empfirstName=" + empfirstName + ", empMiddleName=" + empMiddleName + ", empLastName="
+ empLastName + ", gender=" + gender + ", birthPlace=" + birthPlace + ", marritalStatus="
+ marritalStatus + ", longMedicalTreatmentDescription=" + longMedicalTreatmentDescription + ", suffix="
+ suffix + ", ethnicity=" + ethnicity + ", veteranStatus=" + veteranStatus + ", prefFirstName="
+ prefFirstName + ", preLastName=" + preLastName + ", birthCountry=" + birthCountry + ", citizenship="
+ citizenship + ", citizenshipCountry1=" + citizenshipCountry1 + ", citizenshipCountry2="
+ citizenshipCountry2 + ", visaType=" + visaType + ", email=" + email + ", permanentAddress="
+ permanentAddress + ", presentAddress=" + presentAddress + ", emergencyContactDetails="
+ emergencyContactDetails + ", dob=" + dob + ", visaExp=" + visaExp + ", age=" + age
+ ", noOfChildrens=" + noOfChildrens + ", healthVision=" + healthVision + ", hasPhysicalDisability="
+ hasPhysicalDisability + ", hadLongMedicalTreatment=" + hadLongMedicalTreatment
+ ", hasFourWheelLiscence=" + hasFourWheelLiscence + ", isPresentAddressSame=" + isPresentAddressSame
+ ", passportDetails=" + passportDetails + ", fatherOrHusbandDetails=" + fatherOrHusbandDetails + "]";
}
<label>
<form:checkbox path="personalDetails.isPresentAddressSame" />
Present address same as above
</label>
There was an unexpected error (type=Internal Server Error, status=500).
Invalid property 'personalDetails.isPresentAddressSame' of bean class [com.hr.foundation.models.doc.models.employee.Employee]: Bean property 'personalDetails.isPresentAddressSame' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
您没有包含PersonalDetails
类的getter/setter,但Spring说这就是错误所在。
确保您有这些:
boolean isPresentAddressSame() { ... }
而且
void setPresentAddressSame(boolean value) { ... }
public Boolean isPresentAddressSame() {
return isPresentAddressSame;
}
public void setPresentAddressSame(Boolean isPresentAddressSame) {
if (isPresentAddressSame) {
presentAddress = permanentAddress;
}
this.isPresentAddressSame = isPresentAddressSame;
}
public boolean isPresentAddressSame() {
return isPresentAddressSame;
}
public void setPresentAddressSame(boolean isPresentAddressSame) {
if (isPresentAddressSame) {
presentAddress = permanentAddress;
}
this.isPresentAddressSame = isPresentAddressSame;
}
再次注意,这里的boolean
使用了一个小的b
。
问题内容: 使用嵌套对象的布尔运算符时遇到一些麻烦。这是我的映射: 我想获取恰好包含两个指定ip甚至更多的文档。 假设我的文档具有以下ips: 我想通过使用此过滤器进行搜索来仅检索DOC 1: 问题在于,同时检索了DOC 1和DOC2。 问题答案: 你可以使用你的条件过滤器是这样的: 这是我用来测试的一些代码: http://sense.qbox.io/gist/d6b5f4e4c0d2977a0
问题内容: 我正在使用Nest Elastic并使用Head插件为布尔搜索构建查询,我正在合并多个查询 有关数据库结构和弹性映射的注释 数据库中的每个文档都链接到特定的profileId,后者又具有多个属性 每个文档都有与其关联的多个属性值 在此查询中,我要获取具有特定配置文件和属性值> 30的所有文档,同时要记住,此属性应仅具有ID 2。 SQL查询: 从文档d内部联接attributeValu
问题内容: 我试图解析嵌套的布尔表达式,并分别获取表达式内的各个条件。例如,如果输入字符串是: (A = a OR B = b OR C = c AND((D = d AND E = e)OR(F = f AND G = g))) 我想以正确的顺序得到条件。即 D = d AND E = e OR F = f AND G = g AND A = a OR B = b OR C = c 我正在使用A
问题内容: 我有一个与此对象相似的JSON对象: 现在,我想将“ name”和“ mother”解析为该结构: 我想用struct标签指定JSON字段名称,但是我不知道该用什么作为标签,因为它不是我感兴趣的顶级对象。我在软件包文档中也没有找到关于此的任何内容博客文章JSON和Go。我还测试,和。 问题答案: 遗憾的是,与包不同,该包没有提供访问嵌套值的方法。您需要创建一个单独的Parents结构或
问题内容: 我正在尝试解析JSON对象,其中的一部分看起来像这样: 等等.... 到目前为止,通过执行以下操作,我可以非常简单地解析: 但是,当我尝试将其用作“名称:”时,它将不起作用。 我试过了: 当我尝试这样做时,我得到“找不到JSONObject [业务]”。 当我尝试: 我得到了预期的“找不到JSONObject [名称]”。 我在这里做错了什么?我缺少一些基本的东西。 问题答案: 好吧,
下面是一些示例代码: On doing JSONObject innerObj = (JSONObject) obj.get(“root1”);- 它给出: 线程“main”中出现异常Java . lang . classcastexception:Java . lang . string不能转换为org.json.JSONObject 我尝试了Gson、JSONParser-但仍然无法做到...