Spring提供了HandlerExceptionResolver这个异常解析器接口。
实现HandlerExceptionResolver接口很简单,你只需要实现resolveException(Exception, Handler)这个方法,返回一个ModelAndView对象即可。
实现HandlerExceptionResolver接口很简单,你只需要实现resolveException(Exception, Handler)这个方法,返回一个ModelAndView对象即可。
解决方案 »
- java怎么与mysql相连呢?
- java.lang.IllegalArgumentException: object is not an instance of declaring class
- myeclipse6.5下连接weblogic9出现java.io.StreamCorruptedException:invalid type code:31
- Struts2的标签问题
- httpclient 模拟文件上传失败
- stuts编程中从一个action如何直接转到另一个action?
- Tomcat虚拟目录的设置
- jtable 中的checkbox 的问题
- JBOSS+STRUTS为什么找不到MAPPING啊?谢谢--急啊
- 这个符号代表什么意思?
- struts 向JSP页面传送链表问题
- tomcat5.5.20 中使用log4j 1.2.8 的问题(本人初次使用log4j)
感觉和struts的handler比较类似-
所有的异常交给handler处理
handler能处理的就处理掉了
不能得再抛出来吧
呵呵
IntroductionInterceptor public class ExceptionCatchReturn implements IntroductionInterceptor {
protected static final Log logger = LogFactory
.getLog(ExceptionCatchReturn.class);
/* (non-Javadoc)
* @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
*/
public Object invoke(MethodInvocation invocation) throws Throwable {
System.out.println("Before: invocation=[" + invocation + "]");
Object rval = null;
try {
rval = invocation.proceed();
} catch (Throwable e) {
StringBuffer sb = new StringBuffer();
sb.append(",<ERROR>,");
sb.append(",Exception,");
sb.append(e.getClass().getName());
logger.error(sb, e);
}
System.out.println("Invocation returned");
return rval;
} /* (non-Javadoc)
* @see org.springframework.aop.DynamicIntroductionAdvice#implementsInterface(java.lang.Class)
*/
public boolean implementsInterface(Class arg0) {
// TODO Auto-generated method stub
return false;
}
}