Exception handling 如何在Struts中处理异常
我们如何处理Struts中的异常?请共享示例代码。以下URL应该会有所帮助Exception handling 如何在Struts中处理异常,exception-handling,struts,Exception Handling,Struts,我们如何处理Struts中的异常?请共享示例代码。以下URL应该会有所帮助 使用log4j记录异常 千万不要在struts应用程序中使用System.out.println来捕获异常,因为这很昂贵 log4j的教程> 要处理错误,请执行以下操作: 在struts项目中,使用ActionError对象处理错误对象,并使用ActionErrors对象处理错误 假设 ActionError ae1=new ActionError("err.one"); ActionError ae2=new Ac
ActionError ae1=new ActionError("err.one");
ActionError ae2=new ActionError("err.two");
Action Errors aes=new ActionErrors();
aes.add(ae1);
aes.add(ae2);
saveErrors(request,aes);//store the errors object in request object
要处理异常,请执行以下操作:
1) 使用try和cach块
2) 使用声明性异常处理技术
使用struts-config.xml中的全局exceptons标记来处理异常
无论何时出现异常,它都会执行gen.jsp页面