|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.support.WebContentGenerator
Convenient superclass for any kind of web content generator, like AbstractController and WebContentInterceptor. Can also be used for custom handlers that have their own HandlerAdapter.
Supports HTTP cache control options. The usage of corresponding HTTP headers can be determined via the "useExpiresHeader" and "userCacheControlHeader" properties.
setUseExpiresHeader(boolean)
,
setUseCacheControlHeader(boolean)
,
AbstractController
,
WebContentInterceptor
Field Summary | |
static java.lang.String |
HEADER_CACHE_CONTROL
|
static java.lang.String |
HEADER_EXPIRES
|
static java.lang.String |
HEADER_PRAGMA
|
static java.lang.String |
METHOD_GET
|
static java.lang.String |
METHOD_POST
|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
Constructor Summary | |
WebContentGenerator()
Create a new WebContentGenerator supporting GET and POST methods. |
Method Summary | |
protected void |
applyCacheSeconds(javax.servlet.http.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. |
protected void |
applyCacheSeconds(javax.servlet.http.HttpServletResponse response,
int seconds,
boolean mustRevalidate)
Apply the given cache seconds and generate respective 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. |
protected void |
cacheForSeconds(javax.servlet.http.HttpServletResponse response,
int seconds)
Set HTTP headers to allow caching for the given number of seconds. |
protected void |
cacheForSeconds(javax.servlet.http.HttpServletResponse response,
int seconds,
boolean mustRevalidate)
Set HTTP headers to allow caching for the given number of seconds. |
protected void |
checkAndPrepare(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean lastModified)
Check and prepare the given request and response according to the settings of this generator. |
protected void |
checkAndPrepare(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int cacheSeconds,
boolean lastModified)
Check and prepare the given request and response according to the settings of this generator. |
protected void |
preventCaching(javax.servlet.http.HttpServletResponse response)
Prevent the response from being cached. |
void |
setCacheSeconds(int seconds)
Cache content for the given number of seconds. |
void |
setRequireSession(boolean requireSession)
Set if a session should be required to handle requests. |
void |
setSupportedMethods(java.lang.String[] supportedMethodsArray)
Set the HTTP methods that this content generator should support. |
void |
setUseCacheControlHeader(boolean useCacheControlHeader)
Set whether to use the HTTP 1.1 cache-control header. |
void |
setUseExpiresHeader(boolean useExpiresHeader)
Set whether to use the HTTP 1.0 expires header. |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String METHOD_GET
public static final java.lang.String METHOD_POST
public static final java.lang.String HEADER_PRAGMA
public static final java.lang.String HEADER_EXPIRES
public static final java.lang.String HEADER_CACHE_CONTROL
Constructor Detail |
public WebContentGenerator()
Method Detail |
public final void setSupportedMethods(java.lang.String[] supportedMethodsArray)
public final void setRequireSession(boolean requireSession)
public final void setUseExpiresHeader(boolean useExpiresHeader)
Note: Cache headers will only get applied if caching is enabled for the current request.
public final void setUseCacheControlHeader(boolean useCacheControlHeader)
Note: Cache headers will only get applied if caching is enabled for the current request.
public final void setCacheSeconds(int seconds)
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.
protected final void checkAndPrepare(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean lastModified) throws javax.servlet.ServletException
request
- current HTTP requestresponse
- current HTTP responselastModified
- if the mapped handler provides Last-Modified support
javax.servlet.ServletException
- if the request cannot be handled because a check failedprotected final void checkAndPrepare(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int cacheSeconds, boolean lastModified) throws javax.servlet.ServletException
request
- current HTTP requestresponse
- current HTTP responsecacheSeconds
- positive number of seconds into the future that the
response should be cacheable for, 0 to prevent cachinglastModified
- if the mapped handler provides Last-Modified support
javax.servlet.ServletException
- if the request cannot be handled because a check failedprotected final void preventCaching(javax.servlet.http.HttpServletResponse response)
protected final void cacheForSeconds(javax.servlet.http.HttpServletResponse response, int seconds)
response
- current HTTP responseseconds
- number of seconds into the future that the response
should be cacheable forcacheForSeconds(javax.servlet.http.HttpServletResponse, int, boolean)
protected final void cacheForSeconds(javax.servlet.http.HttpServletResponse response, int seconds, boolean mustRevalidate)
response
- current HTTP responseseconds
- number of seconds into the future that the response
should be cacheable formustRevalidate
- whether the client should revalidate the resource
(typically only necessary for controllers with last-modified support)protected final void applyCacheSeconds(javax.servlet.http.HttpServletResponse response, int seconds)
response
- current HTTP responseseconds
- positive number of seconds into the future that the
response should be cacheable for, 0 to prevent cachingcacheForSeconds(javax.servlet.http.HttpServletResponse, int, boolean)
protected final void applyCacheSeconds(javax.servlet.http.HttpServletResponse response, int seconds, boolean mustRevalidate)
response
- current HTTP responseseconds
- positive number of seconds into the future that the
response should be cacheable for, 0 to prevent cachingmustRevalidate
- whether the client should revalidate the resource
(typically only necessary for controllers with last-modified support)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |