spring学习笔记(六)
1.配置环绕通知
需要实现的接口为 MethodInterceptor
代码举例
1 package com.huawei.aop; 2 3 import org.aopalliance.intercept.MethodInterceptor; 4 import org.aopalliance.intercept.MethodInvocation; 5 6 public class MyMethodInterceptor implements MethodInterceptor 7 { 8 9 @Override 10 public Object invoke(MethodInvocation arg0) throws Throwable 11 { 12 System.out.println("执行前..."); 13 Object obj = arg0.proceed(); 14 System.out.println("执行后..."); 15 return obj; //要返回对象,类似filterChain,返回null,可能导致程序不继续执行 16 } 17 18 }
2.异常通知
需要实现的接口 ThrowAdvice
3.定义切入点
需要在配置文件中配置
1 <!--定义前置通知的切入点--> 2 <bean id="myMethodBeforeAdviceFilter" class="org.springframework.aop.support.NameMatchMethodPointcutAdvice"> 3 <property name="advice" rel="myBeforeAdvice"/> 4 <property name="mappedNames"> 5 <list> 6 <!--这里可以使用正则表达式匹配方法 例如 say*--> 7 <value>sayHello</value> 8 </list> 9 </property> 10 </bean> 11 12 ..... 13 <!--将通知织入代理对象--> 14 <property name="interceptorNames"> 15 <list> 16 <value>myMethodBeforeAdviceFilter</value> 17 <value>myAfterServiceAdvice</value> 18 <value>myMethodInterceptor</value> 19 </list> 20 </property>
转载于:https://www.cnblogs.com/yiliweichinasoft/p/3581302.html
spring学习笔记(六)相关推荐
- Spring学习笔记之MyBatis
系列文章目录 Spring学习笔记 之 Springhttps://blog.csdn.net/weixin_43985478/article/details/124411746?spm=1001.2 ...
- 一箭双雕 刷完阿里P8架构师spring学习笔记+源码剖析,涨薪8K
关于Spring的叙述: 我之前死磕spring的时候,刷各种资料看的我是一头雾水的,后面从阿里的P8架构师那里拿到这两份资料,从源码到案例详细的讲述了spring的各个细节,是我学Spring的启蒙 ...
- JavaEE——Spring学习笔记03【AOP开发】
JavaEE--Spring学习笔记01[Ioc开发的模式] JavaEE--Spring学习笔记02[Spring和Mybatis的整合] JavaEE--Spring学习笔记03[AOP开发] J ...
- JavaEE——Spring学习笔记01【Ioc开发的模式】
JavaEE--Spring学习笔记01[Ioc开发的模式] JavaEE--Spring学习笔记02[Spring和Mybatis的整合] JavaEE--Spring学习笔记03[AOP开发] J ...
- 【Spring学习笔记-MVC-13.2】Spring MVC之多文件上传
作者:ssslinppp 1. 摘要 前篇文章讲解了单文件上传<[Spring学习笔记-MVC-13]Spring MVC之文件上传>http://www.cnblogs.co ...
- Ethernet/IP 学习笔记六
Ethernet/IP 学习笔记六 EtherNet/IP defines two primary types of communications: explicit and implicit (Ta ...
- Spring学习笔记(三) AOP_annotation,AOP_XML
在学习课程以前,听说AOP有种很神秘的感觉,好像很好深的技术.其实原理很简单,使用动态代理的方式给程序增加逻辑.与此相似的有struts2中的filter拦截器. 再讲AOP之前先把需求说一下: 同S ...
- spring学习笔记06-spring整合junit(出现的问题,解决的思路)
spring学习笔记06-spring整合junit(出现的问题,解决的思路) 文章目录 spring学习笔记06-spring整合junit(出现的问题,解决的思路) 3.1测试类中的问题和解决思路 ...
- spring学习笔记01-BeanFactory和ApplicationContext的区别
spring学习笔记01-BeanFactory和ApplicationContext的区别 BeanFactory 和 ApplicationContext 的区别 BeanFa ...
- spring学习笔记02-spring-bean创建的细节问题
spring学习笔记02-spring-bean创建的细节问题 三种创建Bean对象的方式 Bean的作用范围 Bean的生命周期 <?xml version="1.0" e ...
最新文章
- Mastering the Java CLASSPATH
- 七点建议,帮助你编写出简洁、干练的Java代码
- python小案例下载_python 小案例demo06
- 关于haproxy的重定向
- ble芯片 全称_蓝牙芯片都有哪些厂商?一文解答
- springboot指定属性返回_SpringBoot中必须掌握的45个注解
- MyBatis动态SQL使用
- MATLAB在运筹学背包问题的应用,运筹学论文之二维背包问题.docx
- 潮流色彩碰撞C4D几何空间!这样的艺术背景素材,设计师都喜欢
- cwntos使用不了php,centos系统不能使用yum命令怎么解决
- Git Push,Pull,Clone出现SSL certificate problem: unable to get local issuer certificate
- Android跨进程通信--AIDL原理解析
- 计算机保存文件快捷键,保存快捷键是什么,保存文档的快捷键
- 前端技术栈---看完这篇就够了
- 函数表达式与命名函数区别
- 苹果下一代iPhone曝光
- C#InaNutShell中文第七版:TryCatch异常处理
- 一些恶搞的bat小脚本
- 应届毕业生选择国企还是外企好
- php 截取图片大小,PHP截取指定图片大小的方法
热门文章
- linux内存映射起始地址,内存初始化代码分析(三):创建系统内存地址映射
- 2020 CTF暑假夏令营培训Day2 密码学Crypto 部分笔记
- HDOJ水题集合2:最短路(Dijkstra)
- 学委作业管理系统c语言,c语言大作业-学生信息管理系统.doc
- 集训8.21树状数组讲解
- 关于Mysql模糊查询下划线的问题
- qt 处理oracle事务,qt调用oracle存储过程,该怎么处理(2)
- python中tensor与variable_TensorFlow中Variable和get_variable之间的区别
- vivado 使用DDS IP方法
- LeetCode解题思路—循环排序与原地翻转链表(思维导图)