学习帮助网址:http://www.cnblogs.com/S-E-P/archive/2012/01/18/2325253.html
http://blog.csdn.net/ad921012/article/details/49679745
1.配置
<!-- struts2核心包-core --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.5.13</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.5.13</version> </dependency> <!-- spring-context 包含:core,beans,aop 注意:没有包含web --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.0.0.RELEASE</version> </dependency> <!-- spring-core(防止struts降低版本) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.0.0.RELEASE</version> </dependency> <!-- spring-beans(防止struts降低版本) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>5.0.0.RELEASE</version> </dependency> <!-- spring-web的支持 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.0.0.RELEASE</version> </dependency>
<!--这一个是spring的监听器--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
2.我们主要使用resources里的xml文件
<constant name="struts.objectFactory" value="spring"></constant> <package name="mypackage" extends="struts-default"> <action name="hello" class="helloAction"> <result name="success">/WEB-INF/jsp/hello.jsp</result> </action> </package>
<bean id="helloAction" class="com.nf.action.HelloAction"> <property name="myUser" ref="sUser"></property> </bean> <bean id="sUser" class="com.nf.entity.User"> <property name="name" value="鹿晗"></property> <property name="sex" value="其他"></property> </bean>