spring aop expression简单说明

  • spring aop expression简单说明
例1:
<aop:config>
       <aop:pointcut id="userDAO"
           expression="execution(public * cn.dao.IUserDAO.*(..))" />
       <aop:advisor advice-ref="tx" pointcut-ref="userDAO"/>
</aop:config>

在上面的代码中

public                    是指定公共的方法,也可以不写直接写成:execution(* cn.dao.IUserDAO.*(..))
*                         任意返回值
cn.dao.IUserDAO.*         在指定目录下类的任意方法
cn.dao.IUserDAO.insert*  在指定目录下类的所有以inser开头的方法
cn.dao..                  在指定目录下任意类任意方法
(..)                      任意参数
全文:匹配cn.dao.IUserDAO下的所有方法

在execution中是可以有多个的方法,例如:

 

execution(* com.action.userinfoAction..*(..))&&execution(* com.action.memberAction..*(..))&&!execution(* get*(..))&&!execution(* set*(..))

 

例2:

<aop:config>

<aop:advisor pointcut="execution(* *..*ServiceImpl.*(..))" advice-ref="transactionAdvice" />

</aop:config> 

 

在上面代码中

第一个的符号(*) 任意返回值

第二个的符号(*..) 任意包 (test/com.mangocity.test)

第三个的符号(*ServiceImpl) 任意以ServiceImpl结尾的类

第四个的符号(.*) 任意方法

第五个的符号(..) 任意参数

全文:匹配任意包 以ServiceImpl结尾的类下的所有方法

猜你喜欢

转载自wangduorong.iteye.com/blog/2302725
今日推荐