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

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

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

    java學習

    java學習

     

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

    四種通知的執(zhí)行地方:前置通知
    try{
    業(yè)務代碼
    后置通知
    } 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"/>
    <!-- 配置事務切面-->
    <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 楊軍威 閱讀(250) 評論(0)  編輯  收藏


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


    網(wǎng)站導航:
     

    導航

    統(tǒng)計

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 91亚洲国产成人久久精品| 亚洲人成电影网站国产精品| 亚洲国产成人久久综合碰碰动漫3d | 亚洲国产国产综合一区首页| 一级黄色片免费观看| 亚洲成人一区二区| 有色视频在线观看免费高清在线直播| 免费激情视频网站| 成人免费视频国产| 亚洲爆乳AAA无码专区| 免费中文字幕在线| 国产亚洲精品xxx| 免费看男人j放进女人j免费看| 国产亚洲精品va在线| 99免费在线观看视频| 亚洲一区二区三区播放在线| 毛片a级三毛片免费播放| 亚洲国产午夜精品理论片在线播放 | 中文字幕亚洲乱码熟女一区二区| 美女无遮挡拍拍拍免费视频| 亚洲AV无码一区东京热久久| 99久久免费看国产精品| 一区二区亚洲精品精华液| 国产精品国产免费无码专区不卡| 天堂亚洲免费视频| 亚洲成色在线综合网站| 亚洲免费观看网站| 亚洲精品乱码久久久久久V| 亚洲成AⅤ人影院在线观看| a级毛片高清免费视频就| 亚洲综合久久久久久中文字幕| 国产h肉在线视频免费观看| 亚洲乱码无人区卡1卡2卡3| 国产成人精品久久亚洲高清不卡 | 国产免费一区二区视频| 亚洲伊人久久大香线焦| 免费一区二区视频| 日本在线看片免费人成视频1000| 在线观看日本亚洲一区| 在线观看国产区亚洲一区成人| 一级成人a毛片免费播放|