最近在看夏昕的《Spring 开发指南》,在spring配置config.xml里设置commandClass参数的问题...

本文描述了在使用Spring框架配置Bean时遇到的问题及错误信息。具体表现为在设置Bean属性时出现NotWritablePropertyException异常,涉及属性commandClass无法正确设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

好久没来了。这些天一直在看夏昕的《Spring 开发指南》,遇到了一个问题没解决呢。

在Config.xml里有一段代码如下:
<bean id="LoginAction" class="net.xiaxin.action.LoginAction">
 <property name="commandClass">
   <value>net.xiaxin.action.LoginInfo</value>
  </property>
  <property name="fail_view">
   <value>loginfail</value>
  </property>
  <property name="success_view">
   <value>main</value>
  </property>
 </bean> 

在net.xiaxin.action.LoginAction里设置了两个private String属性:fail_view和success_view,并且都提供了相应的setter方法。

运行时报错如下:

DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LoginAction' defined in ServletContext resource [/WEB-INF/Config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'commandClass' of bean class [net.xiaxin.action.LoginAction]: Bean property 'commandClass' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

org.springframework.beans.NotWritablePropertyException: Invalid property 'commandClass' of bean class [net.xiaxin.action.LoginAction]: Bean property 'commandClass' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

oh, my god.
Context initialization failed,
NotWritablePropertyException,
Invalid property 'commandClass' of bean class 
Who can help me? SOS!
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值