转自:http://itlab.idcquan.com/Java/Spring/965349.html
spring aop expression 匹配多个条件 多个表达式
<aop:config>
<aop:pointcut expression="execution(* com.travelsky.ccboy.dao*.find*())|| execution(* com.travelsky.ccboy.dao*.query*())"
id="findCachePointcut" />
<aop:advisor advice-ref="jdbcInterceptor" pointcut-ref="findCachePointcut" />
</aop:config>
在多个表达式之间使用 ||,or表示 或,使用 &&,and表示 与,!表示 非。
上面的代码也可以改写成
<aop:config>
<aop:pointcut expression="(execution(* com.travelsky.ccboy.dao*.find*())) or(execution(* com.travelsky.ccboy.dao*.query*()))"
id="findCachePointcut" />
<aop:advisor advice-ref="jdbcInterceptor" pointcut-ref="findCachePointcut" />
</aop:config>
注意上面两中方法的不同点出了 将 || 改成了 or ,还有就是 每个execution都被()包含起来,建议为了区分不同的表达式 最好都是用()包装。
老外喜欢吧逻辑运算符用OR,and !写,国内一般用|| && !.