Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » web » servlet » support » [javadoc | source]
org.springframework.web.servlet.support
abstract public class: WebContentGenerator [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.support.WebContentGenerator

All Implemented Interfaces:
    ServletContextAware, ApplicationContextAware

Direct Known Subclasses:
    AbstractWizardFormController, OrderFormController, ParameterizableViewController, SimpleFormController, MultiActionController, ServletWrappingController, AnnotationMethodHandlerAdapter, WebContentInterceptor, AbstractUrlViewController, CancellableFormController, AbstractFormController, ServletForwardingController, AbstractCommandController, BaseCommandController, AccountFormController, AbstractClinicForm, UrlFilenameViewController, AbstractController

Convenient superclass for any kind of web content generator, like org.springframework.web.servlet.mvc.AbstractController and org.springframework.web.servlet.mvc.WebContentInterceptor . Can also be used for custom handlers that have their own org.springframework.web.servlet.HandlerAdapter .

Supports HTTP cache control options. The usage of corresponding HTTP headers can be controlled via the "useExpiresHeader", "useCacheControlHeader" and "useCacheControlNoStore" properties.

Field Summary
public static final  String METHOD_GET    HTTP method "GET" 
public static final  String METHOD_HEAD    HTTP method "HEAD" 
public static final  String METHOD_POST    HTTP method "POST" 
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Constructor:
 public WebContentGenerator() 
 public WebContentGenerator(boolean restrictDefaultSupportedMethods) 
Method from org.springframework.web.servlet.support.WebContentGenerator Summary:
applyCacheSeconds,   applyCacheSeconds,   cacheForSeconds,   cacheForSeconds,   checkAndPrepare,   checkAndPrepare,   getCacheSeconds,   getSupportedMethods,   isRequireSession,   isUseCacheControlHeader,   isUseCacheControlNoStore,   isUseExpiresHeader,   preventCaching,   setCacheSeconds,   setRequireSession,   setSupportedMethods,   setUseCacheControlHeader,   setUseCacheControlNoStore,   setUseExpiresHeader
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.support.WebContentGenerator Detail:
 protected final  void applyCacheSeconds(HttpServletResponse response,
    int seconds) 
    Apply the given cache seconds and generate corresponding HTTP headers, i.e. allow caching for the given number of seconds in case of a positive value, prevent caching if given a 0 value, do nothing else. Does not tell the browser to revalidate the resource.
 protected final  void applyCacheSeconds(HttpServletResponse response,
    int seconds,
    boolean mustRevalidate) 
    Apply the given cache seconds and generate respective HTTP headers.

    That is, allow caching for the given number of seconds in the case of a positive value, prevent caching if given a 0 value, else do nothing (i.e. leave caching to the client).

 protected final  void cacheForSeconds(HttpServletResponse response,
    int seconds) 
    Set HTTP headers to allow caching for the given number of seconds. Does not tell the browser to revalidate the resource.
 protected final  void cacheForSeconds(HttpServletResponse response,
    int seconds,
    boolean mustRevalidate) 
    Set HTTP headers to allow caching for the given number of seconds. Tells the browser to revalidate the resource if mustRevalidate is true.
 protected final  void checkAndPrepare(HttpServletRequest request,
    HttpServletResponse response,
    boolean lastModified) throws ServletException 
    Check and prepare the given request and response according to the settings of this generator. Checks for supported methods and a required session, and applies the number of cache seconds specified for this generator.
 protected final  void checkAndPrepare(HttpServletRequest request,
    HttpServletResponse response,
    int cacheSeconds,
    boolean lastModified) throws ServletException 
    Check and prepare the given request and response according to the settings of this generator. Checks for supported methods and a required session, and applies the given number of cache seconds.
 public final int getCacheSeconds() 
    Return the number of seconds that content is cached.
 public final String[] getSupportedMethods() 
    Return the HTTP methods that this content generator supports.
 public final boolean isRequireSession() 
    Return whether a session is required to handle requests.
 public final boolean isUseCacheControlHeader() 
    Return whether the HTTP 1.1 cache-control header is used.
 public final boolean isUseCacheControlNoStore() 
    Return whether the HTTP 1.1 cache-control header value "no-store" is used.
 public final boolean isUseExpiresHeader() 
    Return whether the HTTP 1.0 expires header is used.
 protected final  void preventCaching(HttpServletResponse response) 
    Prevent the response from being cached. See http://www.mnot.net/cache_docs.
 public final  void setCacheSeconds(int seconds) 
    Cache content for the given number of seconds. Default is -1, indicating no generation of cache-related headers.

    Only if this is set to 0 (no cache) or a positive value (cache for this many seconds) will this class generate cache headers.

    The headers can be overwritten by subclasses, before content is generated.

 public final  void setRequireSession(boolean requireSession) 
    Set whether a session should be required to handle requests.
 public final  void setSupportedMethods(String[] methods) 
    Set the HTTP methods that this content generator should support. Default is HEAD, GET and POST.
 public final  void setUseCacheControlHeader(boolean useCacheControlHeader) 
    Set whether to use the HTTP 1.1 cache-control header. Default is "true".

    Note: Cache headers will only get applied if caching is enabled (or explicitly prevented) for the current request.

 public final  void setUseCacheControlNoStore(boolean useCacheControlNoStore) 
    Set whether to use the HTTP 1.1 cache-control header value "no-store" when preventing caching. Default is "true".
 public final  void setUseExpiresHeader(boolean useExpiresHeader) 
    Set whether to use the HTTP 1.0 expires header. Default is "true".

    Note: Cache headers will only get applied if caching is enabled (or explicitly prevented) for the current request.