SpringAop
来源:互联网 发布:明代鸟铳 数据 编辑:程序博客网 时间:2024/06/01 18:23
SpringAop面向切面的思想
就是在某个方法之前和之后插入
package biz;import java.lang.reflect.Method;import java.util.Arrays;import org.springframework.aop.AfterReturningAdvice;public class MyAfter implements AfterReturningAdvice{public void afterReturning(Object arg0, Method arg1, Object[] arg2,Object arg3) throws Throwable {System.out.println("------------后置增强----------------");System.out.println("在"+arg3+"对象上的"+arg1.getName()+"方法");System.out.println("传入参数"+Arrays.toString(arg2));System.out.println("返回的结果"+arg0);}}
package biz;import java.lang.reflect.Method;import java.util.Arrays;import org.springframework.aop.MethodBeforeAdvice;public class MyBefore implements MethodBeforeAdvice{public void before(Method arg0, Object[] arg1, Object arg2)throws Throwable {System.out.println("------------前置增强-------------");System.out.println("在"+arg2+"对象上的"+arg0.getName()+"方法");System.out.println("传入参数"+Arrays.toString(arg1));System.out.println("---------------------------");}}
<bean id="before" class="biz.MyBefore"/><bean id="after" class="biz.MyAfter"/><aop:config><aop:pointcut id="cutpiont" expression="execution(public void print(String))"/><aop:advisor pointcut-ref="cutpiont" advice-ref="before"/><aop:advisor pointcut-ref="cutpiont" advice-ref="after"/></aop:config>
0 0
- SpringAOP
- SpringAOP
- SpringAop
- SpringAOP
- springAOP
- springAOP
- SpringAOP
- SpringAop
- springAOP
- springAOP
- SpringAop
- SpringAOP
- springAOP
- SpringAOP
- SpringAOP
- springaop
- SpringAOP
- springAop
- 关于Mysql入库时间的问题
- 流媒体基础总结
- swustoj手机打字(1185)
- 题目1451:不容易系列之一
- File对象概述
- SpringAop
- 【长篇高能】ReactiveCocoa 和 MVVM 入门
- 封装、继承、多态
- 解析xml与json的总结
- spring4.2.2+quartz2.2.1整合
- javax.servlet.jsp cannot be resolved to a type
- nginx+tomcat 共享session
- 转:solr中facet及facet.pivot理解(整合两篇文章保留参考)
- MySQL数据库/视图