如何继承拦截器堆栈并覆盖其中一个拦截器?

时间:2010-07-23 10:04:06

标签: struts2 interceptorstack

我需要将paramsPrepareParamsStack拦截器堆栈继承到mystack,并且需要覆盖验证拦截器参数。我该怎么做?

2 个答案:

答案 0 :(得分:2)

以下代码执行良好..

<interceptors>
            <interceptor-stack name="ehspre2stack">
                <interceptor-ref name="paramsPrepareParamsStack">
                    <param name="validation.excludeMethods">
                        list,loadedit,remove,execute,reset,loadAdd
                    </param>
                    <param name="exception.logEnabled">true</param>
                    <param name="exception.logLevel">ERROR</param>
                </interceptor-ref>
            </interceptor-stack>
        </interceptors>

答案 1 :(得分:0)

只需将整个堆栈复制到struts.xml中并根据需要覆盖参数:

       <interceptor-stack name="paramsPrepareParamsStack">
            <interceptor-ref name="exception"/>
            <interceptor-ref name="alias"/>
            <interceptor-ref name="params"/>
            <interceptor-ref name="servletConfig"/>
            <interceptor-ref name="prepare"/>
            <interceptor-ref name="i18n"/>
            <interceptor-ref name="chain"/>
            <interceptor-ref name="modelDriven"/>
            <interceptor-ref name="fileUpload"/>
            <interceptor-ref name="checkbox"/>
            <interceptor-ref name="staticParams"/>
            <interceptor-ref name="params"/>
            <interceptor-ref name="conversionError"/>
            <interceptor-ref name="validation">
                <param name="excludeMethods">your,methods,skip,validation</param>
            </interceptor-ref>
            <interceptor-ref name="workflow">
                <param name="excludeMethods">your,methods,skip,validation</param>
            </interceptor-ref>
        </interceptor-stack>