您的位置:首页 > 编程语言 > Java开发

Spring MVC 配置 AOP

2012-02-08 09:10 429 查看
1. 需要使用的jar包
asm-3.3.jar

aspectjrt.jar

aspectjweaver.jar

cglib-nodep-2.1_3.jar

spring-aop.jar

2. XML配置文件

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 
<bean id="aopHandler2" class="com.spring.service.TestAop"></bean>

<aop:config>
<aop:aspect ref="aopHandler2">
<aop:pointcut id="poicut" expression="execution(* com.spring.dao.*.*(..))" /> <!-- 这里可以看spring aop expression简单说明 -->
<!-- method 指出before要调用的方法 -->
<aop:before method="testPrint" pointcut-ref="poicut"/>

</aop:aspect>
</aop:config>
</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: