日期:2014-05-20  浏览次数:20652 次

请教Spring的AOP的问题!
在SSH项目中,用Spring的AOP拦截Action,Spring的配置大致如下:
<aop:config proxy-target-class="true">

<aop:before pointcut="execution(* add())" method="testAfterReturning" />

这种方式有个问题

凡是符合条件的方法都会被织入,假设某个时间段要执行的add方法比较多,我如何取得某一瞬时是哪个类的add方法调用了切面方法。


------解决方案--------------------
可以用aop获取被拦截方法的参数,具体的请参见spring2.5中文手册

核心技术--使用spring进行面向切面变成(AOP)--基于Schema的AOP支持

在线文档是:http://www.redsaga.com/spring_ref/2.0/html/aop.html
中的 6.3. Schema-based AOP support

------解决方案--------------------
切入点处有个参数类型为:
ProceedingJoinPoint

该类型参数可以得到拦截到的类和方法。可参考:http://howsun.blog.sohu.com/106725713.html