日期:2014-05-20 浏览次数:20843 次
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    <bean id="sr" class="com.springmodel.Shiren" />
    <bean id="qs" class="com.springmodel.Qishi">
    </bean>
    
    <aop:config>
        <aop:aspect ref="sr" >
            <aop:pointcut id="qeMethod" expression="execution(* com.springmodel.Qishi.tanXian(*))" />
            <aop:before method="singBefore" pointcut-ref="qeMethod"/>
            <aop:after method="singAlter" pointcut-ref="qeMethod"/>
        </aop:aspect>
    </aop:config>
</beans>
package com.springmodel;
public class Shiren {
    public void singBefore(){
        System.out.println("探险之前sing");
    }
    public void singAlter(){
        System.out.println("探险之后sing");
    }
}
<aop:before method="singBefore" pointcut-ref="qeMethod"/>
            <aop:after method="singAlter" pointcut-ref="qeMethod"/>