首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

请问Spring的AOP的有关问题

2011-12-30 
请教Spring的AOP的问题!在SSH项目中,用Spring的AOP拦截Action,Spring的配置大致如下:aop:config proxy-ta

请教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

热点排行