在aop中获取request

在开发中有时需要在aop中获取request对象
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
HttpServletRequest request = (HttpServletRequest) requestAttributes.
        resolveReference(RequestAttributes.REFERENCE_REQUEST);

备注:上面的代码不能放到另一个线程中,必须属于主线程

 
posted @ 2020-09-25 17:59  炫舞风中  阅读(1542)  评论(0编辑  收藏  举报