zjie-zhang
12/11/2019 - 5:45 AM

切面获取Request,Response,Session

@Around("myMethod()")
 public  Object  doArround(ProceedingJoinPoint point)throws Throwable{
   
   //在spring 切面中获取request、response、session对象
     HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
     HttpServletResponse response= ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
       HttpSession session=request.getSession();
      String methodName = point.getSignature().getName();//获取方法名称
      MethodSignature ms=  (MethodSignature) point.getSignature();//获取方法签名
   BusAuditMethod anno=     ms.getMethod().getAnnotation(BusAuditMethod.class);//获取方法上标记的注解
    // ...
}