1.配置环绕通知

需要实现的接口为  MethodInterceptor

  代码举例

 package com.huawei.aop;

 import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; public class MyMethodInterceptor implements MethodInterceptor
{ @Override
public Object invoke(MethodInvocation arg0) throws Throwable
{
System.out.println("执行前...");
Object obj = arg0.proceed();
System.out.println("执行后...");
return obj; //要返回对象,类似filterChain,返回null,可能导致程序不继续执行
} }

2.异常通知

需要实现的接口 ThrowAdvice

3.定义切入点

需要在配置文件中配置

 <!--定义前置通知的切入点-->
<bean id="myMethodBeforeAdviceFilter" class="org.springframework.aop.support.NameMatchMethodPointcutAdvice">
<property name="advice" rel="myBeforeAdvice"/>
<property name="mappedNames">
<list>
<!--这里可以使用正则表达式匹配方法 例如 say*-->
<value>sayHello</value>
</list>
</property>
</bean> .....
<!--将通知织入代理对象-->
<property name="interceptorNames">
<list>
<value>myMethodBeforeAdviceFilter</value>
<value>myAfterServiceAdvice</value>
<value>myMethodInterceptor</value>
</list>
</property>

spring学习笔记(六)的更多相关文章

  1. Spring学习笔记六:Spring整合Hibernate

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6785323.html  前言:整合概述 Spring整合Hibernate主要是把Hibernate中常用的S ...

  2. Spring Boot 学习笔记(六) 整合 RESTful 参数传递

    Spring Boot 学习笔记 源码地址 Spring Boot 学习笔记(一) hello world Spring Boot 学习笔记(二) 整合 log4j2 Spring Boot 学习笔记 ...

  3. Spring学习笔记(六)—— SSH整合

    一.整合原理 二.整合步骤 2.1 导包 [hibernate] hibernate/lib/required hibernate/lib/jpa 数据库驱动 [struts2] struts-bla ...

  4. 【Spring学习笔记-MVC-3.1】SpringMVC返回Json数据-方式1-扩展

    <Spring学习笔记-MVC>系列文章,讲解返回json数据的文章共有3篇,分别为: [Spring学习笔记-MVC-3]SpringMVC返回Json数据-方式1:http://www ...

  5. java之jvm学习笔记六-十二(实践写自己的安全管理器)(jar包的代码认证和签名) (实践对jar包的代码签名) (策略文件)(策略和保护域) (访问控制器) (访问控制器的栈校验机制) (jvm基本结构)

    java之jvm学习笔记六(实践写自己的安全管理器) 安全管理器SecurityManager里设计的内容实在是非常的庞大,它的核心方法就是checkPerssiom这个方法里又调用 AccessCo ...

  6. spring学习笔记(一) Spring概述

    博主Spring学习笔记整理大部分内容来自Spring实战(第四版)这本书.  强烈建议新手购入或者需要电子书的留言. 在学习Spring之前,我们要了解这么几个问题:什么是Spring?Spring ...

  7. Learning ROS for Robotics Programming Second Edition学习笔记(六) indigo xtion pro live

    中文译著已经出版,详情请参考:http://blog.csdn.net/ZhangRelay/article/category/6506865 Learning ROS for Robotics Pr ...

  8. Java框架spring 学习笔记(十八):事务管理(xml配置文件管理)

    在Java框架spring 学习笔记(十八):事务操作中,有一个问题: package cn.service; import cn.dao.OrderDao; public class OrderSe ...

  9. Typescript 学习笔记六:接口

    中文网:https://www.tslang.cn/ 官网:http://www.typescriptlang.org/ 目录: Typescript 学习笔记一:介绍.安装.编译 Typescrip ...

  10. Spring学习笔记2——表单数据验证、文件上传

    在上一章节Spring学习笔记1——IOC: 尽量使用注解以及java代码中,已经搭建了项目的整体框架,介绍了IOC以及mybatis.第二节主要介绍SpringMVC中的表单数据验证以及文件上传. ...

随机推荐

  1. Codeforces Round 536 (Div. 2) (E)

    layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  2. 母亲的牛奶(milk) (BFS)

    问题 A: 母亲的牛奶(milk) 时间限制: 1 Sec  内存限制: 64 MB提交: 14  解决: 8[提交][状态][讨论版] 题目描述 农民约翰有三个容量分别是A.B.C升的桶,A.B.C ...

  3. 见微知著(三):解析ctf中的pwn--Fastbin和bins的溢出

    1月1号写博客,也是不容易呀!大家新年快乐呀! 先从Fastbin看起,是2015年RCTF的一道pwn题,shaxian.先看看代码的大致流程,随便输入一下: 这个题目关键之处在于堆溢出,对于堆种类 ...

  4. Express处理GET/POST请求(POST请求包含文件)

    Express处理GET/POST请求(POST请求包含文件) GET 使用简洁的pug模板引擎,写一个表单,提交方法是GET 前端页面代码 enctype,默认是application/x-www- ...

  5. [BZOJ 2756] 奇怪的游戏

    Link:https://www.lydsy.com/JudgeOnline/problem.php?id=2756 Algorithm: 比较新颖的题目 首先发现是对矩阵中相邻两数进行操作    & ...

  6. Scala实战高手****第17课:Scala并发编程实战及Spark源码阅读

    package com.wanji.scala.test import javax.swing.text.AbstractDocument.Content import scala.actors.Ac ...

  7. hadoop InputFormat getSplits

    /** Splits files returned by {@link #listStatus(JobConf)} when * they're too big.*/ public InputSpli ...

  8. WCF服务测试工具

    官网地址:http://www.wcfstorm.com/wcf/home.aspx WCFStorm Lite 来进行接口查看及调试,如下所示.

  9. 重新学习vue基础

    1.创建vue实例 var vm = new Vue({ el: '#example', //选择元素 data: {a:1} //基本数据 }) 2.模板语法 (一)基本语法 <span> ...

  10. 设置cookie和查找cookie的方法

    1.设置cookie(名称,值,过期时间) function setCookie(key,value,d){ if(d === undefined){ document.cookie = encode ...