spring在非controlle项目中获取当前request
public static HttpServletRequest getCurrentRequest() throws IllegalStateException { ServletRequestAttributes requestAttrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (requestAttrs == null) { throw new IllegalStateException("当前线程中不存在 Request 上下文"); } return requestAttrs.getRequest(); }