struts2中配置struts.xml文件,让全项目出现异常都跳转到同一个异常页面

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
	"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="struts2" namespace="/" extends="struts-default">
         <!-- 定义全局result -->			
        <global-results>	
            <!-- 定义名为exception的全局result -->
            <result name="exception">/Exception.jsp</result>	
        </global-results>	

        <!-- 定义全局异常映射 -->	
        <global-exception-mappings>	
            <!-- 捕捉到Exception异常(所有异常)时跳转到exception所命名的视图上 -->
            <exception-mapping exception="java.lang.Exception" result="exception"/>
        </global-exception-mappings>
    </package>
</struts>

猜你喜欢

转载自kzby2003.iteye.com/blog/1626641