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 ...
随机推荐
- pat 甲级 1072. Gas Station (30)
1072. Gas Station (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A gas sta ...
- What and How in an Application
Basically, two concerntrations: 1. What: business docs and prototype design 2. How: technical docs a ...
- 树莓派个人实测 Q&A(最新修改使用Manjaro连接远程桌面) (二)
以下内容使用和http://www.eeboard.com/bbs/thread-5191-1-1.html所在的帖子一样的风格,不过原作者是window下的操作,本人的都是在manjaro linu ...
- Python 多核 多线程 调度
参考: http://www.oschina.net/translate/pythons-hardest-problem https://news.ycombinator.com/item?id=58 ...
- anaconda 安装
1. 安装: 参考博客:https://blog.csdn.net/qq_36851515/article/details/82956150 2. 更新包: 更新失败:conda httperror ...
- 记录: 一次解决整型溢出攻击(使用scala,隐式转换)
最近项目遇到一次整型溢出攻击 有一个功能,玩家购买num个物品. 每个物品花费14货币. 客户端限制玩家只能购买 1-9999个该物品. 但是某玩家通过技术手段,获得了客户端的运行权限. 于是发送协议 ...
- Python Challenge 第十关
第十关是一张牛的图片和一行字:len(a[30])=?.图片中的牛是一个链接,点开后进入一个新页面,只有一行字: a = [1, 11, 21, 1211, 111221, 看来要知道第31个数多长, ...
- 浅谈前端性能优化(PC版)
前端的性能优化是一个很宽泛的概念,最终目的都是为了提升用户体验,改善页面性能.面试的时候经常会遇到问谈谈性能优化的手段,这个我分几大部分来概述,具体细节需要自己再针对性的去搜索,只是提供一个索引(太多 ...
- 联通积分兑换的Q币怎么兑换到QQ上
可登录联通积分商城http://jf.10010.com 查询和兑换Q币, 1,通过联通积分商城自主兑换,提交订单扣除积分成功后,10010端口将自动为您下发验证码短信. 2,在有效期内登陆Q币充值 ...
- Codeforces Round #454 C. Shockers【模拟/hash】
C. Shockers time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...