1. 自定义异常类com.ebuair.exception.UsernameException和PasswordException
2. 在struts.xml文件中配置
<exception-mappingresult="usernameexception"exception="com.ebuair.exception.UsernameException"></exception-mapping>
<exception-mappingresult="passwordexception"exception="com.ebuair.exception.PasswordException"></exception-mapping>
<resultname="usernameexception">/usernameexception.jsp</result>
<resultname="passwordexception">/passwordexception.jsp</result>
3. 对于struts.xml文件来说局部有优于全集。
注意<global-results>要定义在<global-exception-mappings>之前。
4. 在Action中定义的异常与结果是局部的,也可以定义全局的异常与结果,局部的总是优于全局的。
如果定义成全局,可以为所有Action所公用,而局部的异常与结果只能被当前的Action所独享,不能为其他Action所共享。