zoukankan      html  css  js  c++  java
  • aop

    @Aspect
    @Component
    public class WeiXinRegister {
    
    
      @Pointcut("execution(public * com.workit.wx.*.controller..*.*(..))")
        public void pointcut() {
    
        }
    
        /**
         * 该标签声明次方法是一个前置通知:在目标方法开始之前执行
         *
         * @param joinPoint
         */
        @Before("pointcut()")
        public void beforMethod(JoinPoint joinPoint) throws Throwable {
            Object[] args = joinPoint.getArgs();
            HttpServletRequest request = null;
            HttpServletResponse response = null;
            for (int i = 0; i < args.length; i++) {
                if (args[i] instanceof HttpServletRequest) {
                    request = (HttpServletRequest) args[i];
                }
                if (args[i] instanceof HttpServletResponse) {
                    response = (HttpServletResponse) args[i];
                }
            }
            if (request == null || response == null) {
                return;
            }
    
        }
    <!-- aop开启注解扫描 -->
    <context:component-scan base-package="com.workit.wx.aspect"></context:component-scan>
    <aop:aspectj-autoproxy proxy-target-class="true" />
    这个放在spring mvc 配置文件中

  • 相关阅读:
    Flume-概述-安装
    Hive-函数
    Hive_查询
    Hive-DML数据操作
    JDBC-文档
    Hive-DDL数据定义
    Hive-数据类型
    理解RESTful架构
    REST介绍
    [转]详述DHCP服务器的三种IP分配方式
  • 原文地址:https://www.cnblogs.com/root429/p/9251337.html
Copyright © 2011-2022 走看看