码迷,mamicode.com
首页 > 其他好文 > 详细

aop实现记录后端用户访问

时间:2020-07-22 20:25:22      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:请求头   就是   业务   ble   通过   obj   vat   span   记录   

记录:

  访问ip, 请求链接, 请求参数, 请求头, 返回信息...

 

问题1:

  如何实现aop切片的就是Controller中的请求方法?

    监听xxxController下的所有方法?

      担心Controller中有部分方法是普通方法,例如private String datePares(Date date)这种

    使用过滤器?

      此业务不应该用过滤器

    使用拦截器?

      要求参照前面aop的例子完成,所以先不考虑。

  解决方案:

   spring的切点定义允许通过注解定位,结合execution表达式完成切点。

  @Pointcut(" @annotation(org.springframework.web.bind.annotation.PostMapping)"
      + " || @annotation(org.springframework.web.bind.annotation.PutMapping)"
      + " || @annotation(org.springframework.web.bind.annotation.DeleteMapping)"
      + " || @annotation(org.springframework.web.bind.annotation.RequestMapping)")
  private void requestAspect() {
  }

  @Pointcut("execution(* com.duoyu.home..* (..))")
  private void backendAspect() {

  }

  @Around("requestAspect() && backendAspect()")
  public Object run(ProceedingJoinPoint point) throws Throwable {

 

问题2:

  处理方法中如何得到HttpServletRequest?

  

 

 

。。。。。。。

 

aop实现记录后端用户访问

标签:请求头   就是   业务   ble   通过   obj   vat   span   记录   

原文地址:https://www.cnblogs.com/aigeileshei/p/13362639.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!