<?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-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd "> <aop:config> <aop:aspect id="log" ref="logging"> <aop:pointcut id="selectAll" expression="execution(* com.tutorialspoint.Student.setName(**)) and args(name)"/> <aop:before pointcut-ref="selectAll" arg-names="name" method="beforeAdvice"/> <aop:after pointcut-ref="selectAll" arg-names="name" method="afterAdvice"/> <!-- aop:after-returning pointcut-ref="selectAll" returning="retVal" method="afterReturningAdvice"/--> <!-- aop:after-throwing pointcut-ref="selectAll" throwing="ex" method="AfterThrowingAdvice"/--> </aop:aspect> </aop:config> <!-- Definition for student bean --> <bean id="student" class="com.tutorialspoint.Student"> <property name="name" value="Zara" /> <property name="age" value="11"/> </bean> <!-- Definition for logging aspect --> <bean id="logging" class="com.tutorialspoint.Logging"/> </beans>
SPRING AOP 如何添加参数
最新推荐文章于 2024-08-18 21:54:20 发布