<!-- 配置AOP-->
<aop:config>
<!-- 配置切入點表達式 id屬性用於指定表達式的唯一標識.expression屬性用於指定表達式內容
此標籤寫在aop:aspect標籤內部只能當前切面使用。
它還可以寫在aop:aspect外面,此時就變成了所有切面可用-->
<aop:pointcut id="pt1" expression="execution( * *..*.*(..))"/>
<!-- 配置切面-->
<aop:aspect id="logAdvice" ref="logger">
<!-- 配置前置通知:在切入點方方法執行之前執行-->
<aop:before method="printLog" pointcut-ref="pt1" ></aop:before>
<!-- 配置後置通知:在切入點方法正常執行之後值.-->
<aop:after-returning method="afterReturning" pointcut-ref="pt1"></aop:after-returning>
<!-- 配置異常通知:在切入點方法執行產生異常之後執行.它和後置通知只能執行一個-->
<aop:after-throwing method="atterThrowingProint" pointcut-ref="pt1"></aop:after-throwing>
<!-- 配置最終通知:無論切入點方法是否正常執行它都會在其後面執行-->
<aop:after method="afterPrintLog" pointcut-ref="pt1"></aop:after>
</aop:aspect>
</aop:config>
spring AOP(面向切面編程)四種通知類型- xml配置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.