struts.xml ,中实例化了action ,<action name="adduser" class="com.jsw.struts2.action.UserAction">
而在spring 中也实例了action,这样实例化对象无法setter ,出现null ,
<bean id="UserAction" class="com.jsw.struts2.action.UserAction">
<property name="userservice" ref="UserService"/>
</bean>
不妨修改为
struts.xml
<action name="adduser" class="这里就是spring 注册的action bean 的id">
eg:<action name="adduser" class="UserAction">
spring.xml
<bean id="UserAction" class="com.jsw.struts2.action.UserAction" scope="prototype">
<property name="userservice" ref="UserService"/>
</bean>