Class RequestContextHolder
java.lang.Object
org.springframework.web.context.request.RequestContextHolder
Holder class to expose the web request in the form of a thread-bound
RequestAttributes object. The request will be inherited
by any child threads spawned by the current thread if the
inheritable flag is set to true.
Use RequestContextListener or
RequestContextFilter to expose
the current web request. Note that
DispatcherServlet
already exposes the current request by default.
- Since:
- 2.0
- Author:
- Juergen Hoeller, Rod Johnson
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic RequestAttributesReturn the RequestAttributes currently bound to the thread.static @Nullable RequestAttributesReturn the RequestAttributes currently bound to the thread.static voidReset the RequestAttributes for the current thread.static voidsetRequestAttributes(@Nullable RequestAttributes attributes) Bind the given RequestAttributes to the current thread, not exposing it as inheritable for child threads.static voidsetRequestAttributes(@Nullable RequestAttributes attributes, boolean inheritable) Bind the given RequestAttributes to the current thread.
- 
Constructor Details- 
RequestContextHolderpublic RequestContextHolder()
 
- 
- 
Method Details- 
resetRequestAttributespublic static void resetRequestAttributes()Reset the RequestAttributes for the current thread.
- 
setRequestAttributesBind the given RequestAttributes to the current thread, not exposing it as inheritable for child threads.- Parameters:
- attributes- the RequestAttributes to expose
- See Also:
 
- 
setRequestAttributespublic static void setRequestAttributes(@Nullable RequestAttributes attributes, boolean inheritable) Bind the given RequestAttributes to the current thread.- Parameters:
- attributes- the RequestAttributes to expose, or- nullto reset the thread-bound context
- inheritable- whether to expose the RequestAttributes as inheritable for child threads (using an- InheritableThreadLocal)
 
- 
getRequestAttributesReturn the RequestAttributes currently bound to the thread.- Returns:
- the RequestAttributes currently bound to the thread,
or nullif none bound
 
- 
currentRequestAttributesReturn the RequestAttributes currently bound to the thread.Exposes the previously bound RequestAttributes instance, if any. Falls back to the current JSF FacesContext, if any. - Returns:
- the RequestAttributes currently bound to the thread
- Throws:
- IllegalStateException- if no RequestAttributes object is bound to the current thread
- See Also:
 
 
-