SpringMvc aop before
1.config.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans> <bean id="logBefore" class="com.gc.action.LogBefore"></bean>
<bean id="timeBook" class="com.gc.action.TimeBook"></bean>
<bean id="logBeforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<!-- advice 要加入的代码 -->
<property name="advice">
<ref bean="logBefore"></ref>
</property> <!--指定do开头的方法 -->
<property name="patterns">
<value>.*do.*</value>
</property>
</bean> <!-- LogBefore -->
<bean id="logProxy1" class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 该配置也可以去掉 -->
<property name="proxyInterfaces">
<value>com.gc.action.ITimeBook</value>
</property> <!-- 被代理的对象 -->
<property name="target">
<ref bean="timeBook"></ref>
</property>
<!--引入代理配置 -->
<property name="interceptorNames">
<list>
<value>logBeforeAdvisor</value>
</list>
</property> </bean>
</beans>
2.LogBefore
package com.gc.action; import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; public class LogBefore implements MethodBeforeAdvice{ @Override
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
System.out.println("before aop 前"); // TODO Auto-generated method stub } }
3.ITimeBook
package com.gc.action; public interface ITimeBook { public void doAudit(String name);
}
4.TimeBook
package com.gc.action; public class TimeBook implements ITimeBook { @Override
public void doAudit(String name) {
// TODO Auto-generated method stub
System.out.println("laaaaaaaaaaaaa");
} }
5.测试
ApplicationContext context=new FileSystemXmlApplicationContext("config-before.xml");
ITimeBook tb=(ITimeBook)context.getBean("logProxy1");
tb.doAudit("xiaox");
SpringMvc aop before的更多相关文章
- springmvc aop 事务配置
对应的中文: 任意公共方法的执行: execution(public * *(..)) 任何一个以“set”开始的方法的执行: execution(* set*(..)) AccountService ...
- spring(一)--spring/springmvc/spring+hibernate(mybatis)配置文件
这篇文章用来总结一下spring,springmvc,spring+mybatis,spring+hibernate的配置文件 1.web.xml 要使用spring,必须在web.xml中定义分发器 ...
- 任务调度--spring下的任务调度quartz
之前写过Timer实现任务调度,这篇文章用来写一下在spring下使用quartz实现任务调度,直接上代码: 定义任务对象: package com; /** * 1. 定义任务对象 * * @aut ...
- springMVC Aspect AOP 接口耗时统计
在接口开发中,我们通常需要统计接口耗时,为后续接口性能做统计.在springMVC中可以用它的aop来记录日志. 1.在spring配置文件中开启AOP <!--*************** ...
- SpringMVC集成AOP错误:java lang classnotfoundexception org aspectj lang joinpoint
记录自己出现的问题,Spring AOP 使用测试类测试没问题,在SpringMVC启动服务器时出现java lang classnotfoundexception org aspectj lang ...
- springMVC+MyBatis+Spring 整合(4) ---解决Spring MVC 对AOP不起作用的问题
解决Spring MVC 对AOP不起作用的问题 分类: SpringMVC3x+Spring3x+MyBatis3x myibaits spring J2EE2013-11-21 11:22 640 ...
- springmvc集成aop记录操作日志
首先说明一下,这篇文章只做了记录日志相关事宜 具体springmvc如何集成配置aop对cotroller进行拦截,请看作者的另一篇文章 http://www.cnblogs.com/guokai87 ...
- springmvc配置aop
直接看代码 springmvc中的配置aop对 controller和它的子包进行拦截 springmvc中的配置 <!--xml头部配置需要有这几行代码--> xmlns:aop=&qu ...
- spring框架整合springMVC时关于AOP无法切入的问题
最开始springMVC的配置为: spring的配置为: 分析可知道spring的配置正确,由于在springmvc中已经扫描了@Controller相关的注解,所以就不需要再次扫描了,由于spri ...
随机推荐
- 洛谷 [P3377] 左偏树(可并堆)
可并堆,就是可以合并的堆 注意并查集不能路径压缩,不然删除根节点时会出错 #include <iostream> #include <cstring> #include < ...
- 使用非对称算法RSA实现加解密和使用签名算法SHA1WithRSA、MD5withRSA生成签名以及验签
不啰嗦,直接上源码 package com.hudai.platform.manager.util; import java.io.ByteArrayOutputStream; import java ...
- [LeetCode] Search in Rotated Sorted Array II 二分搜索
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this ...
- poj 2280 Islands and Bridges 哈密尔顿路 状压dp
题目链接 题意 给定一个\(N\)个点的无向图,求一条哈密尔顿路径\(C_1C_2...C_n\),使其\(value\)最大. \(value\)的计算方式如下:\[\begin{aligned}v ...
- linux 实现共享内存同步
本文主要对实现共享内存同步的四种方法进行了介绍. 共享内存是一种最为高效的进程间通信方式,进程可以直接读写内存,而不需要任何数据的拷贝.它是IPC对象的一种. 为了在多个进程间交换信息,内核专门留出了 ...
- Day 21 Object_oriented_programming_2
继承实现原理 python中的类可以同时继承多个父类,继承的顺序有两种:深度优先和广度优先. 一般来讲,经典类在多继承的情况下会按照深度优先的方式查找,新式类会按照广度优先的方式查找 示例解析: 没有 ...
- 安装glibc错误链接导致系统崩溃,u盘启动紧急救援模式下修复系统。
Sln 命令 创建动态符号链接 用法 sln source dest 故障案例:一个误操作 导致了一个不小的故障,输入所有命令都无效,直接系统无法启动. 故障描述 sln /usr/lib64/l ...
- hdu 3657 最小割的活用 / 奇偶方格取数类经典题 /最小割
题意:方格取数,如果取了相邻的数,那么要付出一定代价.(代价为2*(X&Y))(开始用费用流,敲升级版3820,跪...) 建图: 对于相邻问题,经典方法:奇偶建立二分图.对于相邻两点连边2 ...
- 机器学习3_EM算法与混合高斯模型
①EM算法: http://www.cnblogs.com/jerrylead/archive/2011/04/06/2006936.html 李航 <统计学习方法>9.1节 ②混合高斯模 ...
- Codeforces Gym10081 A.Arcade Game-康托展开、全排列、组合数变成递推的思想
最近做到好多概率,组合数,全排列的题目,本咸鱼不会啊,我概率论都挂科了... 这个题学到了一个康托展开,有点用,瞎写一下... 康托展开: 适用对象:没有重复元素的全排列. 把一个整数X展开成如下形式 ...