Spring3.1异常通知ThrowsAdvice说明

[size=small][b]引言:[/b][/size]

笔者直接从Spring2.x跳到Spring3.1,在用到org.springframework.aop.ThrowsAdvice时,发现ThrowsAdvice接口内部已经被清空,立即迷茫了。怎么个说法?

[size=small][b]正文:[/b][/size]

遇到这样的问题,啥也别说,先找Spring3.1的官方文档瞅瞅看有没说明(要没的话3.0继续找)……

两分钟后,找到下面一段说明:


Throws advice
Throws advice is invoked after the return of the join point if the join point threw an exception. Spring
offerstypedthrowsadvice.Notethatthismeansthatthe
org.springframework.aop.ThrowsAdvice interface does not contain any methods: It is a tag
interface identifying that the given object implements one or more typed throws advice methods. These
should be in the form of:

afterThrowing([Method, args, target], subclassOfThrowable)

Only the last argument is required. The method signatures may have either one or four arguments,
depending on whether the advice method is interested in the method and arguments.
...


大意是,ThrowsAdvice不包含任何方法了,只是一个接口标志符,方便类自己选择一个或多个通知方法。简单地说放开了“必须实现XXX的限制”

这样上面引文中的“afterThrowing”参数中的方括号中的部分便可为可选部分,而最后一个参数也可以随意指定为自己想要的任何实现了“Throwable”的对象。

(结束)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值