spring基础----->aop全配置下的配置切入点

1.当我们不使用注解@pointcut来进行配置切入点,以xml配置方式如何去表达切入点了?

答:Xml配置切入点,由两个标签起作用:

1.1<aop:config....>标签下的<aop:pointcut>标签,

1.2<aop:aspect...>标签下的<aop:pointcut>标签.


2.一般情况下我们都是结合使用<aop:config>和<aop:aspect>下的pointcut标签

    如何结合使用?

    答:<aop:config>标签有两个属性:  id和 expression  如:<aop:pointcut id="mypointcut" expression="execution(* test.*.*(..))"/> 在此情况下mypointcut就可以代表execution(* test.*.*(..))切入表达式,然后在<aop:aspect...>标签下使用pointcut-ref="mypointcut" 就可以引用,那么他们就达到了结合使用的效果

  

   分别使用的话

   <aop:config>下的pointcut就显得非常无力了,因为它可以反复被引用,而且它也是为了被引用而写的

   <aop:aspect>下的pointcut是在当前的通知语句里面起作用  如:<aop:before pointcut=""execution(* test.*.*(..))" method=""> 出去该标签则无效了!


3.结合使用<aop:config>和<aop:aspect>的pointcut标签案例(全xml配置无注解)

  <aop:config>
                  <aop:pointcut  id="mypointcut" expression="execution(* aoptest.*.*(..))"/>
                  <aop:aspect id="aspectid" ref="aspect">
                      <aop:before  pointcut-ref="mypointcut" method="play"/>
                  </aop:aspect>
          </aop:config>
           
           
           <bean id="person" class="aoptest.person"/>
           <bean id="aspect" class="aoptest.aspect"/>
           
          </beans>


今天学习xml配置切入点到此为止!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值