简体   繁体   中英

Global Exception in struts2

I am trying to configure Global exceptions in struts.xml. when I include the global-exception mapping tag, the project is not getting start. I am getting the following message in log,

Jul 27, 2010 6:33:07 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Jul 27, 2010 6:33:07 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/ehspreg2] startup failed due to previous errors
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.

Struts.xml file is,

<package name="default" extends="struts-default">

        <result-types>
            <result-type name="tiles"
                class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>

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


        <default-interceptor-ref name="ehspre2stack" />

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception"
                result="exception" />
        </global-exception-mappings>

        <global-results>
            <result name="exception">jsp/common/error.jsp</result>
        </global-results>


        <action name="home">
            <result type="tiles" name="success">showHome</result>
        </action>

        <action name="login"
            class="com.mmm.ehspreg2.web.action.WelcomeAction">
            <result type="tiles" name="local">showLogin</result>
        </action>
</package>

Your <global-exception-mappings> needs to be defined after your <global-results> according to the struts.xml dtd .

    <global-results>
        <result name="exception">jsp/common/error.jsp</result>
    </global-results>

    <global-exception-mappings>
        <exception-mapping exception="java.lang.Exception"
            result="exception" />
    </global-exception-mappings>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM