Java Module name,NotReadablePropertyException:Bean类的无效属性'moduleName'

I am getting the following exception in Spring MVC application:

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.(BindStatus.java:149)

JSP Code

Module Name

Spring Controller

@RequestMapping(value = "/submitSurvey", method = RequestMethod.POST)

public String submitSurvey(@ModelAttribute("surveyModule")SurveyModule sm, Model model){

surveyService.setSurveyModule(sm);

return "surveyHome";

}

Bean: 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;

}

}

The property moduleName exist in the bean class. While I am able to use the property to get data, why I am getting this error? How can I correct this?

解决方案

Do note that the error says

Invalid property 'moduleName' of bean class [java.lang.String]

which means that ElResolver resolves surveyModule as String and not as a SurveyModule class. That means that there is an assignment with the same key, that is causing your problem. Check the keys you use for storing in other model attributes or session, also check that there is no

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值