【发布时间】:2012-01-15 14:42:59
【问题描述】:
我正在使用 Aspect 在基于 spring mvc 的应用程序中记录活动。我正在使用 @controller 注释来定义我的应用程序中的任何控制器。我在两个不同的包中有两个不同的控制器说
- com.package1 包含控制器 1 类,我们将其命名为 AController
- com.package2 包含控制器 2 类,我们将其命名为 BController
我可以通过使用
将方面应用到一个特定的控制器包<aop:config>
<aop:pointcut id="pointcut1"
expression="execution(* package1.*.*(..))"
id="policy1" />
<aop:aspect ref="aspect1" order="1">
<aop:before pointcut-ref="pointcut1" method="before" arg-names="joinPoint" />
<aop:after-returning returning="returnValue" arg-names="joinPoint, returnValue" pointcut-ref="pointcut1" method="after" />
</aop:aspect>
</aop:config>
<bean id="aspect1" class="com......aspectclass" />
我的问题是如何在 expression(* package1...(..))** 中指定多个不同的包。
现在我为每个包声明一个单独的切入点,并且在方面为每个切入点声明一个单独的 aop:before 和 aop:after 条目。但我认为这应该是定义多个包切入点的理想方式。
【问题讨论】:
标签: spring aop spring-aop pointcut aspect