http://blog.csdn.net/yiyiquegai/article/details/7903135
web.xml如下
- <context-param>
- <param-name>contextConfigLoaction</param-name>
- <param-value>classpath:applicationContext.xml</param-value>
- </context-param>
修改applicationContext.xml配置文件如下:
- <bean id="surroundAdvice" class="com.aspect.SurroundAdvice"/>
- <bean id="beforeAdvice" class="com.aspect.BeforeAdvice"/>
- <bean id="afterAdvice" class="com.aspect.AfterAdvice"/>
- <bean id="owner" class="com.aspect.Owner"/>
- <bean id="proxyFactoryBean" class="org.springframework.aop.framework.ProxyFactoryBean">
- <property name="proxyInterfaces" value="com.aspect.ProxyInter"/>
- <property name="target" ref="owner"/>
- <property name="interceptorNames">
- <list>
- <value>surroundAdvice</value>
- <value>beforeAdvice</value>
- <value>afterAdvice</value>
- </list>
- </property>
- </bean>
- <aop:config>
- <aop:pointcut id="serviceMethod"
- expression="execution(* com.aspect.ProxyInter.rent(..))"/>
- <aop:advisor advice-ref="surroundAdvice" pointcut-ref="serviceMethod"/>
- </aop:config>