第一步:导入Struts2jar包+springIOC的jar包和Aop的Jar包
第二步:建立applicationContext.xml文件+struts.xml文件+web.xml文件
web.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.5" 3 xmlns="http://java.sun.com/xml/ns/javaee" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 6 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 7 8 <context-param> 9 <description> 10 将applicationContext.xml放在src目录下,依然能够找到该配置文件 11 </description> 12 13 <param-name>contextConfigLocation</param-name> 14 <param-value>classpath:applicationContext.xml</param-value> 15 </context-param> 16 17 <listener> 18 <description> 19 项目启动时,创建Ioc容器,将项目下所有费数据类创建对象,并注入,建立对象之间的关系 20 </description> 21 22 <listener-class> 23 org.springframework.web.context.ContextLoaderListener</listener-class> 24 </listener> 25 26 27 28 <filter> 29 <filter-name>struts2</filter-name> 30 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 31 </filter> 32 33 <filter-mapping> 34 <filter-name>struts2</filter-name> 35 <url-pattern>/*</url-pattern> 36 </filter-mapping> 37 38 </web-app>