直接看代码

springmvc中的配置aop对 controller和它的子包进行拦截

springmvc中的配置

<!--xml头部配置需要有这几行代码-->
xmlns:aop="http://www.springframework.org/schema/aop"
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd <aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="logAopAction" class="com.um.framework.baseware.webadmin.modules.controller.core.LogAopAction"/>
<!--aop执行操作的类-->
package com.um.framework.baseware.webadmin.modules.controller.core;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; @Aspect
public class LogAopAction {
//配置接入点,如果不知道怎么配置,可以百度一下规则
@Pointcut("execution(* com.um.framework.baseware.webadmin.modules.controller..*.*(..))")
private void anyMethod(){
System.out.println("log记录------------------------");
}//定义一个切入点 @Before("anyMethod() && args(name)")
public void doAccessCheck(String name){
System.out.println(name);
System.out.println("前置通知--------------------------");
} @AfterReturning("anyMethod()")
public void doAfter(){
System.out.println("后置通知-------------------------");
} @After("anyMethod()")
public void after(){
System.out.println("最终通知---------------------------");
} @AfterThrowing("anyMethod()")
public void doAfterThrow(){
System.out.println("例外通知-----------------------------------");
} @Around("anyMethod()")
public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable{
System.out.println("进入环绕通知------------------------------");
Object object = pjp.proceed();//执行该方法
System.out.println("退出方法--------------------");
return object;
}
}

springmvc配置aop的更多相关文章

  1. springmvc配置AOP的两种方式

    spingmvc配置AOP有两种方式,一种是利用注解的方式配置,另一种是XML配置实现. 应用注解的方式配置: 先在maven中引入AOP用到的依赖 <dependency> <gr ...

  2. springmvc 中配置aop

    之前自己搭建了springmvc+spring+mybaits/hibernate 的框架,并在applicationcontext.xml中配置了aop,但 发现aop根本不生效,而不用框架的话则可 ...

  3. 【JavaEE】SSH+Spring Security基础上配置AOP+log4j

    Spring Oauth2大多数情况下还是用不到的,主要使用的还是Spring+SpringMVC+Hibernate,有时候加上SpringSecurity,因此,本文及以后的文章的example中 ...

  4. springmvc集成aop记录操作日志

    首先说明一下,这篇文章只做了记录日志相关事宜 具体springmvc如何集成配置aop对cotroller进行拦截,请看作者的另一篇文章 http://www.cnblogs.com/guokai87 ...

  5. SpringMVC配置实例

    一.SpringMVC概述 MVCII模式实现的框架技术 Model--业务模型(Biz,Dao...) View--jsp及相关的jquery框架技术(easyui) Contraller--Dis ...

  6. springMvc配置拦截器无效

    说明 springMvc配置国际化拦截器失败,点击页面按钮切换中英文无效,排查发现没有进入 LocaleChangeInterceptor 类中,判断拦截器没有起作用,那么是什么原因导致拦截器无效,通 ...

  7. Spring学习记录(十三)---基于xml文件配置AOP

    上一篇讲了用注解配置AOP,现在讲用xml怎么配置AOP 其实逻辑是一样的,只是用xml的方法,要把这种逻辑写出来,告诉spring框架去执行. 例子:这里的例子和上一篇的例子一样.换成xml方式 / ...

  8. springMVC之AOP

    AOP(Aspect-Oriented Programming,面向切面编程) 切面(Aepect):横切关注点(跨越应用程序多个模块的功能)被模块化的对象: 通知(Advice):切面必须要完成的工 ...

  9. Spring-boot 配置Aop获取controller里的request中的参数以及其返回值

    首先在你的Maven的pom文件里加入aop的依赖: <dependency> <groupId>org.springframework.boot</groupId> ...

随机推荐

  1. 给VIM和Terminal配色:Solarized

    给VIM和Terminal配色:Solarized 最近在学习使用VIM.我选择Solarized配色.相信很多人也都在用. 官网地址: http://ethanschoonover.com/sola ...

  2. Deep Belief Network简介

    Deep Belief Network简介 1. 多层神经网络存在的问题 常用的神经网络模型, 一般只包含输入层, 输出层和一个隐藏层: 理论上来说, 隐藏层越多, 模型的表达能力应该越强.但是, 当 ...

  3. MongoDB的一些用法(转藏)

    MongoDB是目前工作中经常使用到的NoSQL数据库. 本博客只记录相关理论知识和技巧,涉及到实践的部分都会单开Blog来记录实践过程. ------------------------------ ...

  4. xls===>csv tables===via python ===> sqlite3.db

    I've got some files which can help a little bit to figure out where people are from based on their I ...

  5. TOGAF架构内容框架之内容元模型(下)

    TOGAF架构内容框架之内容元模型(下) 2.2 治理扩展(Governance Extensions) 治理扩展元模型内容 治理扩展部分的意图在于引入额外的,并且与支持运营治理的目标和业务服务相关的 ...

  6. MapXtrem + Asp.net 地图随窗体改变大小

    在B/S框架下,MapXtreme都是基于图片的,也就是说在客户端显示的地图实际上都是一张图片. 地图控件 <cc1:MapControl ID="/> 在调试模式下,编译后的地 ...

  7. apache+php+mysql的分布安装

    一.Apache+php+mysql的版本: Apache:2.2.22 Mysql:5.5.24 Php:5.3.13 二.apache+php+mysql的分布安装 注意:卸载软件之前要先停止服务 ...

  8. es6笔记1^_^let、string、number、math

    ECMAScript是一种由Ecma国际(前身为欧洲计算机制造商协会,英文名称是European Computer Manufacturers Association)通过ECMA-262标准化的脚本 ...

  9. java获取登陆用户的IP地址

    /** * 通过HttpServletRequest返回IP地址 * @param request HttpServletRequest * @return ip String * @throws E ...

  10. [ios2]tableView去除空行的singleLine

    http://www.winddisk.com/2013/03/29/tableview%E5%8E%BB%E9%99%A4%E7%A9%BA%E8%A1%8C%E7%9A%84singleline/ ...