<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java學(xué)習(xí)

    java學(xué)習(xí)

     

    spring中aop 的配置實(shí)現(xiàn)

    四種通知的執(zhí)行地方:前置通知
    try{
    業(yè)務(wù)代碼
    后置通知
    } catch{
    異常通知
    } finally{
    最終通知
    }
    1.需要的jar包:aspectjrt.jar,aspectjweaver.jar,cglib-nodep-2.1.3.jar
    2.在配置文件中加入

    <?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:p="http://www.springframework.org/schema/p"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           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
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

    ">
    <bean id="myXmlAspect" class="com.yjw.aspect.MyXmlAspect"/>
    <!-- 配置事務(wù)切面-->
    <aop:config>
     <aop:aspect ref="myXmlAspect">
      <aop:pointcut expression="execution(* com.yjw.dao..*.*(..))" id="pointcut"/>
      <aop:before method="beforeAdvice" pointcut-ref="pointcut"/>
      <aop:after-returning method="afterReturningAdvice" returning="value" pointcut-ref="pointcut"/>
      <aop:after-throwing method="exceptionAdvice" pointcut-ref="pointcut" throwing="ex"/>
      <aop:after method="afterAdvice" pointcut-ref="pointcut"/>
     </aop:aspect>
    </aop:config>
    </beans>

     

    package com.yjw.aspect;

     

     

    public class MyXmlAspect {


     
     //前置通知

     public void  beforeAdvice(){
      System.out.println("前置通知");
     }
     //異常通知,接收異常信息

     public  void  exceptionAdvice(Exception  ex){
      System.out.println("異常出現(xiàn)"+ex.getMessage());
     }
     //后置通知,可以接收方法的返回值
     
     public  void  afterReturningAdvice(Object  value){
      System.out.println("后置通知"+value);
     }
     //最終通知

     public  void  afterAdvice(){
      System.out.println("after");
     }
    }

     

    posted on 2013-04-29 11:50 楊軍威 閱讀(246) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 成人黄网站片免费视频| 一级做a爰片久久免费| 亚洲中文字幕AV每天更新| 羞羞视频在线观看免费| 无码人妻一区二区三区免费n鬼沢| 免费观看成人毛片a片2008| 亚洲国产人成中文幕一级二级| 久久亚洲成a人片| 亚洲日韩看片无码电影| 免费福利在线视频| 国产成人在线免费观看| 日韩亚洲AV无码一区二区不卡| 最新亚洲人成网站在线观看| 久久久久久一品道精品免费看 | 日本亚洲高清乱码中文在线观看| 色视频色露露永久免费观看 | 亚洲一卡2卡三卡4卡有限公司| 国产精品免费大片| 免费观看国产精品| 亚洲爱情岛论坛永久| 免费人成在线观看69式小视频| 久久久久亚洲AV成人网人人软件| 亚洲日本久久久午夜精品| 免费精品一区二区三区第35| 亚洲精品在线视频观看| 国产免费爽爽视频在线观看| 亚洲欧洲日产国码在线观看| 国产无遮挡裸体免费视频在线观看| 亚洲精品美女在线观看| 最新中文字幕电影免费观看| 亚洲视频免费观看| 免费在线看黄的网站| 亚洲国产精品久久网午夜| 大胆亚洲人体视频| 亚洲av色香蕉一区二区三区| 成人女人A级毛片免费软件| 91亚洲va在线天线va天堂va国产| 色妞WWW精品免费视频| 怡红院免费的全部视频| 中文字幕亚洲天堂| 国产福利在线观看免费第一福利|