一.配置异常通知的步骤(AspectJ 方式)
二.异常通知(Schema-based 方式)
public class MyThrow implements ThrowsAdvice{
// public void afterThrowing(Method m, Object[] args,Object target, Exception ex) {
// System.out.println("执行异常通知");
// }
public void afterThrowing(Exception ex) throws Throwable {
System.out.println("执行异常通过-schema-base 方式");
}
}
<bean id="mythrow" class="com.bjsxt.advice.MyThrow"></bean>
<aop:config>
<aop:pointcut expression="execution(* com.bjsxt.test.Demo.demo1())" id="mypoint"/>
<aop:advisor advice-ref="mythrow" pointcut-ref="mypoint" />
</aop:config>
<bean id="demo" class="com.bjsxt.test.Demo"></bean>