struts2+spring项目整合步骤

来源:互联网 发布:docker 软件 编辑:程序博客网 时间:2024/05/14 14:08
一、框架的引入和整合
1.导入struts2和spring所需的jar包
2.导入spring支持web的jar包(org.springframework.web-3.0.5.RELEASE.jar)
导入spring整合struts2的jar包(struts2-spring-plugin-2.2.3.jar)
3.添加配置文件:struts.xml,applicationContext.xml,log4j.properties
4.配置web.xml:
<filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    
    
    <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>


二、框架的使用