zoukankan      html  css  js  c++  java
  • Aop JoinPoint方法详解

    重要方法
            /*获取参数的值数组*/
            Object[] args = point.getArgs();                                    //  [1] 参数的值
            /*获取目标对象(被加强的对象)*/
            Object target = point.getTarget();
            /*获取signature 该注解作用在方法上,强转为 MethodSignature*/
            MethodSignature signature = (MethodSignature) point.getSignature();
            /*方法名*/
            String signatureName = signature.getName();                         //  findById
            /*参数名称数组(与args参数值意义对应)*/
            String[] parameterNames = signature.getParameterNames();            //  [i] 参数名称
            /*获取执行的方法对应Method对象*/
            Method method = signature.getMethod();                              //  public void com.draymond.aop2.service.UserService.findById(int)
            /*获取返回值类型*/
            Class returnType = signature.getReturnType();                       //  void
            /*获取方法上的注解*/
            WebAnnotation webAnnotation = method.getDeclaredAnnotation(WebAnnotation.class);

    常用的其他对象 request / response

         // 获取request/response(ThreadLocal模式)
            RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
            ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
            HttpServletRequest request = servletRequestAttributes.getRequest();
            HttpServletResponse response = servletRequestAttributes.getResponse();
  • 相关阅读:
    原生JS中Ajax的使用方法
    back-to-top回到顶部
    atom插件
    git 命令操作
    常用font-family
    上传按钮美化
    mongodb
    GraphicsMagick命令
    enctype=“multipart/form-data”详解
    操作符
  • 原文地址:https://www.cnblogs.com/draymond/p/12670123.html
Copyright © 2011-2022 走看看