步骤:
1.
导入Spring的包和
struts2-spring-plugin-2.0.11.2.jar
2.
web.xml中加
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
3.
strust.xml中<struts>加
<constant name="struts.objectFactory"
value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
4.
strust.xml中
<action name="list" method="list" class="messageAction">
<result>/list.jsp</result>
</action>
5.
applicationContext.xml中
<bean id="messageAction" class="action.MessageAction" scope="prototype">
<property name="messageService">
<ref bean="messageService" />
</property>
</bean>
其中<action> 中的
class属性必须和<bean> 中的
id属性一致,<bean> 中的class属性才是真正的类名。