[struts2] struts 中页面访问出错怎样定位到错误页面

struts.xml
<?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
	"http://struts.apache.org/dtds/struts-2.1.7.dtd">

<struts>
	<constant name="struts.i18n.encoding" value="utf-8"/>
	<constant name="struts.devMode" value="true"/>
	<constant name="struts.i18n.reload" value="true"/>
	<constant name="struts.configuration.xml.reload" value="true"/>
	<constant name="struts.serve.static.browserCache" value="false"/>
	<constant name="struts.ui.theme" value="simple"/>
	
	<package name="ssh-default" extends="struts-default" namespace="/">
		<default-action-ref name="mainAction"/>
		<global-results>
			<result name="error">
				/WEB-INF/jsp/error.jsp
			</result>
		</global-results>
		<action name="mainAction" class="com.tarena.web.action.MainAction">
			<result name="main" type="redirect">
				/user/userAction!regUser
			</result>
		</action>
	</package>
	
	<include file="struts/struts-user.xml"/>
</struts>


struts-user.xml
<?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
	"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
	<package name="ssh-user" extends="ssh-default" namespace="/user">
		<global-exception-mappings>
			<exception-mapping result="error" exception="java.lang.Exception"/>
		</global-exception-mappings>
		<action name="userAction" class="com.tarena.web.action.UserAction">
			<result name="reg_user">
				/WEB-INF/jsp/reg_user.jsp
			</result>
		</action>
	</package>
</struts>

当用户访问如  http://localhost:8080/ssh/user/userAction!aaasdf 这样的没有对应方法的页面时

可以跳转到自定义的错误页面

注意点: struts-user.xml 中的 extends 为 ssh-default

你可能感兴趣的:(exception,struts,File,Class,encoding)