登录/注册
JAVA知识库
Struts2_Spring 整合
转自:互联网
整合Spring,换句话说,也就是让spring的IOC功能为我们的struts action注入逻辑组件首先需要加载struts2 - spring - plugin - 2.0.6.jar这个包,这个是关键,他可以帮我们把struts2和spring仅仅整合在一起
首先是web.xml
< ?xml version = "1.0"encoding = "utf-8" ? ><web - app version = "2.4"xmlns = "http://java.sun.com/xml/ns/j2ee"xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > <context - param > <param - name > contextConfigLocation < /param-name> <param-value>/WEB - INF / bean.xml < /param-value> </context - param > <listener > <listener - class > org.springframework.web.context.ContextLoaderListener < /listener-class> </listener > <filter > <filter - name > struts2 < /filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter - class > </filter> <filter-mapping> <filter-name>struts2</filter - name > <url - pattern >/*</url-pattern> </filter-mapping> <filter> <filter-name>aaa</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp </filter-class> </filter> <filter-mapping> <filter-name>aaa</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>