非controller层获取response和request对象

ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = attrs.getResponse();
HttpServletRequest request = attrs.getRequest();

原文地址:https://www.cnblogs.com/alex-xyl/p/11214601.html