0
我收到以下異常在Spring MVC應用程序:NotReadablePropertyException:無效的屬性 'MODULENAME' bean類的
org.springframework.beans.NotReadablePropertyException: Invalid property 'moduleName' of bean class [java.lang.String]: Bean property 'moduleName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:726)
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:717)
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:149)
JSP代碼
<form:form method="post" action="/submitSurvey" modelAttribute="surveyModule" >
<form:label path="moduleName">Module Name</form:label>
<form:input path="moduleName" />
<input type="submit" value="Save"/>
</form:form>
春季控制器
@RequestMapping(value = "/submitSurvey", method = RequestMethod.POST)
public String submitSurvey(@ModelAttribute("surveyModule")SurveyModule sm, Model model){
surveyService.setSurveyModule(sm);
return "surveyHome";
}
豆:SurveyModule.java
@Entity
@Table(name="SURVEYMODULE")
public class SurveyModule {
@Id
@Column(name="SurveyModuleId")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer surveyModuleId;
private String moduleName;
public Integer getSurveyModuleId() {
return surveyModuleId;
}
public void setSurveyModuleId(Integer surveyModuleId) {
this.surveyModuleId = surveyModuleId;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
}
酒店MODULENAME存在於bean類。雖然我能夠使用該屬性來獲取數據,但爲什麼我得到這個錯誤?我該如何解決這個問題?
你是正確的地方。我糾正了它。現在一切正常。非常感謝。 – 2014-11-21 18:06:05