spring 攔截器
阿新 • • 發佈:2019-01-30
<!--配置目標 orange --> <bean id="orange" class="com.zking.spring.Orange"></bean> <!-- 配置通知 fruit 環繞通知 --> <bean id="fruit" class="com.zking.spring.Fruit"></bean> <!-- 配置前置通知 --> <bean id="miet" class="com.zking.spring.Miet"></bean> <!-- 配置後置通知 --> <bean id="miet2" class="com.zking.spring.Miet2"></bean> <!-- 過濾通知:前置 --> <bean id="myBeofre" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="miet"></property> <property name="pattern" value=".*at.*"></property> </bean> <!-- 過濾通知:後置 --> <bean id="myafter" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice" ref="miet2"></property> <property name="pattern" value=".*at.*"></property> </bean> <!-- 配置混合代理物件 --> <bean id="myspring" class="org.springframework.aop.framework.ProxyFactoryBean"> <!-- 引入目標 --> <property name="target" ref="orange"></property> <!-- 目標實現介面 --> <property name="proxyInterfaces"> <list> <value>com.zking.spring.Actor</value> </list> </property> <!-- 引入通知 --> <property name="interceptorNames" > <list> <idref bean="myBeofre"/><!-- 引入前置通知 --> <idref bean="fruit"/><!-- 引入環繞通知 --> <idref bean="myafter"/><!-- 引入後置通知 --> </list> </property> </bean> </beans>
以上為攔截器程式碼