@Nullable open static fun findWebApplicationContext(request: HttpServletRequest, @Nullable servletContext: ServletContext): WebApplicationContext
Look for the WebApplicationContext associated with the DispatcherServlet that has initiated request processing, and for the global context if none was found associated with the current request. The global context will be found via the ServletContext or via ContextLoader's current context.
NOTE: This variant remains compatible with Servlet 2.5, explicitly checking a given ServletContext instead of deriving it from the request.
request - current HTTP request
servletContext - current servlet context
Return
the request-specific WebApplicationContext, or the global one if no request-specific context has been found, or null if none
Since
4.2.1
See Also
DispatcherServlet#WEB_APPLICATION_CONTEXT_ATTRIBUTEWebApplicationContextUtils#getWebApplicationContext(ServletContext)ContextLoader#getCurrentWebApplicationContext()
@Nullable open static fun findWebApplicationContext(request: HttpServletRequest): WebApplicationContext
Look for the WebApplicationContext associated with the DispatcherServlet that has initiated request processing, and for the global context if none was found associated with the current request. The global context will be found via the ServletContext or via ContextLoader's current context.
NOTE: This variant requires Servlet 3.0+ and is generally recommended for forward-looking custom user code.
request - current HTTP request
Return
the request-specific WebApplicationContext, or the global one if no request-specific context has been found, or null if none
Since
4.2.1
See Also
#findWebApplicationContext(HttpServletRequest, ServletContext)ServletRequest#getServletContext()ContextLoader#getCurrentWebApplicationContext()