欢迎使用CSDN-markdown编辑器

来源:互联网 发布:java编写乘法表 编辑:程序博客网 时间:2024/06/06 03:08








        <!-- 3.1 前置通知             <aop:before method="" pointcut="" pointcut-ref=""/>                method : 通知,及方法名                pointcut :切入点表达式,此表达式只能当前通知使用。                pointcut-ref : 切入点引用,可以与其他通知共享切入点。            通知方法格式:public void myBefore(JoinPoint joinPoint){                参数1:org.aspectj.lang.JoinPoint  用于描述连接点(目标方法),获得目标方法名等            例如:        <aop:before method="myBefore" pointcut-ref="myPointCut"/>        -->        <!-- 3.2后置通知  ,目标方法后执行,获得返回值            <aop:after-returning method="" pointcut-ref="" returning=""/>                returning 通知方法第二个参数的名称            通知方法格式:public void myAfterReturning(JoinPoint joinPoint,Object ret){                参数1:连接点描述                参数2:类型Object,参数名 returning="ret" 配置的            例如:        <aop:after-returning method="myAfterReturning" pointcut-ref="myPointCut" returning="ret" />        -->        <!-- 3.3 环绕通知             <aop:around method="" pointcut-ref=""/>            通知方法格式:public Object myAround(ProceedingJoinPoint joinPoint) throws Throwable{                返回值类型:Object                方法名:任意                参数:org.aspectj.lang.ProceedingJoinPoint                抛出异常            执行目标方法:Object obj = joinPoint.proceed();            例如:        <aop:around method="myAround" pointcut-ref="myPointCut"/>        -->        <!-- 3.4 抛出异常            <aop:after-throwing method="" pointcut-ref="" throwing=""/>                throwing :通知方法的第二个参数名称            通知方法格式:public void myAfterThrowing(JoinPoint joinPoint,Throwable e){                参数1:连接点描述对象                参数2:获得异常信息,类型Throwable ,参数名由throwing="e" 配置            例如:        <aop:after-throwing method="myAfterThrowing" pointcut-ref="myPointCut" throwing="e"/>        -->        <!-- 3.5 最终通知 -->                   <aop:after method="myAfter" pointcut-ref="myPointCut"/>    </aop:aspect></aop:config>
原创粉丝点击