Alex_TD

Spring ---AOP(2)

 

方法二:

1.创建对象Aopdemo  方法 show(){...}

2.添加     <bean id="aopdemo" class="com....."/>

    <aop:config > 

     <aop:aspect ref="aopdemo">

        <aop:pointcut id="os" expression="execution(* *.*(..))"/>

        <aop:before method="show"  pointcut-ref="os"/>

     </aop:aspect>

    </aop:config>

3.方法三:注解方式

     1. XML配置添加 :<aop:autoproxy  ....>  自动代理

            <bean id="aopspect" class="com.xx.xx.Aopsect"/>

     2. 创建对象 :

             @Aspect

            public class Aopsect{

                @Before|@After|@Around("execute=(* com.xx.xx类.*(..))")

                public void  show(){

                       实现简单的方法

              };   

                }                     

posted on 2020-02-20 20:21  Alex_TD  阅读(98)  评论(0编辑  收藏  举报