标签:private except ast path opera rda define r.java value
提示错误信息:
Unable to instantiate Action, userAction, defined for ‘user_registPage‘ in namespace ‘/‘Error creating bean with name ‘userAction‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userService‘ of bean class [com.itcast.shop.user.action.UserAction]: Bean property ‘userService‘ is not writable or has an invalid setter method. Did you mean ‘userservive‘? - action - file:/D:/Program%20Files%20(x86)/apache-tomcat-9.0.1/webapps/shop/WEB-INF/classes/struts.xml:36:56 com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:320) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:401) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:201) org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:57) org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:32) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:60) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564) org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79) org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:141)
出现此问题的原因是在ApplicationContext.xml中配置有问题,里面的bean的属性名称用 与 注入的类名称不一致
applicationContext.xml
<!-- 用户模块的Action -->
<bean id="userAction" class="com.itcast.shop.user.action.UserAction" scope="prototype">
<property name="userService" ref="userService"/>
</bean>
userAction
private UserDao userdao;
private UserService userService;
public void setUserservive(UserService userService) {
this.userService = userService;
}
红色部分名称要一致。
SSH框架整合遇到的错误——org.springframework.beans.NotWritablePropertyException:
标签:private except ast path opera rda define r.java value
原文地址:https://www.cnblogs.com/aishanyishi/p/9248684.html