RequestContextHolder与RequestContextUtils

org.springframework.web.servlet.support.RequestContextUtils

在spring-webmvc中, 主要用来获取WebApplicationContext

org.springframework.web.context.request.RequestContextHolder

在spring-web中, 主要用来获取当前线程的RequestAttributes对象, 通过RequestAttributes再获得ServletRequestAttributes, 通过ServletRequestAttributes来获取最终的httpServletRequest

这里也支持servlet3+之后的异步request, 可以在子线程中直接使用RequestContextHolder

原文地址:https://www.cnblogs.com/Jeely/p/10811931.html