日期:2014-05-17  浏览次数:20707 次

Struts2配置问题
Struts has detected an unhandled exception: 

Messages: Invalid property 'curveobjService' of bean class [com.hysm.web.action.cur.CurveObjAction]: Bean property 'curveobjService' is not writable or has an invalid setter method. Did you mean 'curveObjService'? 
Error creating bean with name 'curveobjAction' defined in ServletContext resource [/WEB-INF/action.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'curveobjService' of bean class [com.hysm.web.action.cur.CurveObjAction]: Bean property 'curveobjService' is not writable or has an invalid setter method. Did you mean 'curveObjService'? 
Unable to instantiate Action, curveobjAction, defined for 'queryCur' in namespace '/cur'Error creating bean with name 'curveobjAction' defined in ServletContext resource [/WEB-INF/action.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'curveobjService' of bean class [com.hysm.web.action.cur.CurveObjAction]: Bean property 'curveobjService' is not writable or has an invalid setter method. Did you mean 'curveObjService'? 

CurveObjAction文件:
public class CurveobjAction extends JqGridBaseAction{
private CCurveObj curveobj;
private Pager<CCurveObj> pager;
private CurveobjServiceImpl curveobjService;
struts-xml文件:
<struts>
  <package name="curJson" namespace="/cur" extends="json-default">
  <!-- 查询单位 -->
  <action name="queryCurveObj" class="curveobjAction" method="search">
  <result type="json"></result>
  </action>
  </package>
<package name="curDef" namespace="/cur" extends="alu-default">
  <action name="queryCur" class="curveobjAction" method="">
  <result name="success">/jsp/config/curveobj.jsp</result>
  </action>
</package>
</struts>
action.xml文件:
<bean id="curveobjAction"
class="com.hysm.web.action.cur.CurveobjAction" scope="prototype">
<property name="curveobjService" ref="curveobjService"></property> 
</bean>
service.xml:
  <bean id="curveobjService" class="com.hysm.web.service.impl.CurveObjServiceImpl"> 
  </bean>



------解决方案--------------------
大胆猜测楼主用了 spring,如果不是,也可以试一下。
private CurveobjServiceImpl curveobjService;
换成
private CurveobjService curveobjService; 相同的get set方法也是。
说明白点,就是类型改成 接口,不要用接口实现类。
如果我猜对了,你想问spring底层原因,私信。