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();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM