Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.servlet.support
Class RequestContextUtils

    java.lang.Object
      org.springframework.web.servlet.support.RequestContextUtils

    public abstract class RequestContextUtils

extends java.lang.Object

Utility class for easy access to request-specific state which has been set by the `DispatcherServlet`.

Supports lookup of current WebApplicationContext, LocaleResolver, Locale, ThemeResolver, Theme, and MultipartResolver.

Since:
  03.03.2003
Author:
  Juergen Hoeller
See Also:
  `RequestContext`, `DispatcherServlet`

Constructor Summary
`RequestContextUtils()`

Method Summary
`static FlashMapManager` | `getFlashMapManager(javax.servlet.http.HttpServletRequest request)` Return the FlashMapManager instance to save flash attributes with before a redirect.
`static java.util.Map<java.lang.String,?>` | `getInputFlashMap(javax.servlet.http.HttpServletRequest request)` Return a read-only `Map` with "input" flash attributes saved on a previous request.
`static java.util.Locale` | `getLocale(javax.servlet.http.HttpServletRequest request)` Retrieves the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet (if available), falling back to the request's accept-header Locale.
`static LocaleResolver` | `getLocaleResolver(javax.servlet.http.HttpServletRequest request)` Return the LocaleResolver that has been bound to the request by the DispatcherServlet.
`static FlashMap` | `getOutputFlashMap(javax.servlet.http.HttpServletRequest request)` Return the "output" FlashMap with attributes to save for a subsequent request.
`static Theme` | `getTheme(javax.servlet.http.HttpServletRequest request)` Retrieves the current theme from the given request, using the ThemeResolver and ThemeSource bound to the request by the DispatcherServlet.
`static ThemeResolver` | `getThemeResolver(javax.servlet.http.HttpServletRequest request)` Return the ThemeResolver that has been bound to the request by the DispatcherServlet.
`static ThemeSource` | `getThemeSource(javax.servlet.http.HttpServletRequest request)` Return the ThemeSource that has been bound to the request by the DispatcherServlet.
`static WebApplicationContext` | `getWebApplicationContext(javax.servlet.ServletRequest request)` Look for the WebApplicationContext associated with the DispatcherServlet that has initiated request processing.
`static WebApplicationContext` | `getWebApplicationContext(javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)` 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RequestContextUtils

    public RequestContextUtils()

Method Detail

### getWebApplicationContext

    public static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request)
                                                          throws java.lang.IllegalStateException

  Look for the WebApplicationContext associated with the DispatcherServlet that has initiated request processing.

  Parameters:
    `request` - current HTTP request
  Returns:
    the request-specific web application context
  Throws:
    `java.lang.IllegalStateException` - if no servlet-specific context has been found

### getWebApplicationContext

    public static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request,
                                                                 javax.servlet.ServletContext servletContext)
                                                          throws java.lang.IllegalStateException

  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. This method is useful to allow components outside the framework, such as JSP tag handlers, to access the most specific application context available.

  Parameters:
    `request` - current HTTP request
    `servletContext` - current servlet context
  Returns:
    the request-specific WebApplicationContext, or the global one if no request-specific context has been found
  Throws:
    `java.lang.IllegalStateException` - if neither a servlet-specific nor a global context has been found

### getLocaleResolver

    public static LocaleResolver getLocaleResolver(javax.servlet.http.HttpServletRequest request)

  Return the LocaleResolver that has been bound to the request by the DispatcherServlet.

  Parameters:
    `request` - current HTTP request
  Returns:
    the current LocaleResolver, or `null` if not found

### getLocale

    public static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)

  Retrieves the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet (if available), falling back to the request's accept-header Locale.

  Parameters:
    `request` - current HTTP request
  Returns:
    the current locale, either from the LocaleResolver or from the plain request
  See Also:
    `getLocaleResolver(javax.servlet.http.HttpServletRequest)`, `ServletRequest.getLocale()`

### getThemeResolver

    public static ThemeResolver getThemeResolver(javax.servlet.http.HttpServletRequest request)

  Return the ThemeResolver that has been bound to the request by the DispatcherServlet.

  Parameters:
    `request` - current HTTP request
  Returns:
    the current ThemeResolver, or `null` if not found

### getThemeSource

    public static ThemeSource getThemeSource(javax.servlet.http.HttpServletRequest request)

  Return the ThemeSource that has been bound to the request by the DispatcherServlet.

  Parameters:
    `request` - current HTTP request
  Returns:
    the current ThemeSource

### getTheme

    public static Theme getTheme(javax.servlet.http.HttpServletRequest request)

  Retrieves the current theme from the given request, using the ThemeResolver and ThemeSource bound to the request by the DispatcherServlet.

  Parameters:
    `request` - current HTTP request
  Returns:
    the current theme, or `null` if not found
  See Also:
    `getThemeResolver(javax.servlet.http.HttpServletRequest)`

### getInputFlashMap

    public static java.util.Map<java.lang.String,?> getInputFlashMap(javax.servlet.http.HttpServletRequest request)

  Return a read-only `Map` with "input" flash attributes saved on a previous request.

  Parameters:
    `request` - the current request
  Returns:
    a read-only Map, or `null`
  See Also:
    `FlashMap`

### getOutputFlashMap

    public static FlashMap getOutputFlashMap(javax.servlet.http.HttpServletRequest request)

  Return the "output" FlashMap with attributes to save for a subsequent request.

  Parameters:
    `request` - current request
  Returns:
    a `FlashMap` instance, never `null`
  See Also:
    `FlashMap`

### getFlashMapManager

    public static FlashMapManager getFlashMapManager(javax.servlet.http.HttpServletRequest request)

  Return the FlashMapManager instance to save flash attributes with before a redirect.

  Parameters:
    `request` - the current request

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD