struts-2.5.2配置

1.将apps下的showcase 中 WEB-INF lib下的jar包拷入项目lib下

2.将struts.xml放在src下,删除没必要的 添加类似

   <?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
    "http://struts.apache.org/dtds/struts-2.5.dtd">

<struts>

    <constant name="struts.objectFactory" value="spring"></constant>
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    
    <include file="struts-default.xml" />  
    <package name="default" extends="struts-default" namespace="/"  strict-method-invocation="false">
     <global-allowed-methods>*</global-allowed-methods>
        <action name="register" class="com.ssh.action.RegisterAction" method="execute">  
            <result name="input">/Register.jsp</result>  
            <result name="success">/Success.jsp</result>  
            <result name="error">/Fail.jsp</result>  
        </action>  
    </package>

</struts>



3.在WEB-INF 下的web.xml中添加类似

    <filter>
        <filter-name>struts-prepare</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareFilter</filter-class>
    </filter>

    <filter>
        <filter-name>struts-execute</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts-prepare</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <filter-mapping>
        <filter-name>struts-execute</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>
            org.apache.struts2.tiles.StrutsTilesListener
        </listener-class>
    </listener>
   

    <listener>
        <listener-class>org.apache.struts2.dispatcher.listener.StrutsListener</listener-class>
    </listener>

如果listener不加会报错

4.拷入applicationContext.xml到web.xml同级别
    内容暂时只保留beans部分
展开阅读全文

没有更多推荐了,返回首页