java.lang.Object | |||
↳ | org.springframework.context.support.ApplicationObjectSupport | ||
↳ | org.springframework.web.context.support.WebApplicationObjectSupport | ||
↳ | org.springframework.web.servlet.support.WebContentGenerator |
Known Direct Subclasses |
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 controlled via the "useExpiresHeader", "useCacheControlHeader" and "useCacheControlNoStore" properties.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | METHOD_GET | HTTP method "GET" | |||||||||
String | METHOD_HEAD | HTTP method "HEAD" | |||||||||
String | METHOD_POST | HTTP method "POST" |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new WebContentGenerator which supports
HTTP methods GET, HEAD and POST by default.
| |||||||||||
Create a new WebContentGenerator.
| |||||||||||
Create a new WebContentGenerator.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the number of seconds that content is cached.
| |||||||||||
Return the HTTP methods that this content generator supports.
| |||||||||||
Return whether a session is required to handle requests.
| |||||||||||
Return whether the HTTP 1.1 cache-control header is used.
| |||||||||||
Return whether the HTTP 1.1 cache-control header value "no-store" is used.
| |||||||||||
Return whether the HTTP 1.0 expires header is used.
| |||||||||||
Cache content for the given number of seconds.
| |||||||||||
Set whether a session should be required to handle requests.
| |||||||||||
Set the HTTP methods that this content generator should support.
| |||||||||||
Set whether to use the HTTP 1.1 cache-control header.
| |||||||||||
Set whether to use the HTTP 1.1 cache-control header value "no-store"
when preventing caching.
| |||||||||||
Set whether to use the HTTP 1.0 expires header.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Apply the given cache seconds and generate respective HTTP headers.
| |||||||||||
Apply the given cache seconds and generate corresponding HTTP headers,
i.e.
| |||||||||||
Set HTTP headers to allow caching for the given number of seconds.
| |||||||||||
Set HTTP headers to allow caching for the given number of seconds.
| |||||||||||
Check and prepare the given request and response according to the settings
of this generator.
| |||||||||||
Check and prepare the given request and response according to the settings
of this generator.
| |||||||||||
Prevent the response from being cached.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
|
Create a new WebContentGenerator which supports HTTP methods GET, HEAD and POST by default.
Create a new WebContentGenerator.
restrictDefaultSupportedMethods | true if this
generator should support HTTP methods GET, HEAD and POST by default,
or false if it should be unrestricted
|
---|
Create a new WebContentGenerator.
supportedMethods | the supported HTTP methods for this content generator |
---|
Return the number of seconds that content is cached.
Return the HTTP methods that this content generator supports.
Return whether a session is required to handle requests.
Return whether the HTTP 1.1 cache-control header is used.
Return whether the HTTP 1.1 cache-control header value "no-store" is used.
Return whether the HTTP 1.0 expires header is used.
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.
Set whether a session should be required to handle requests.
Set the HTTP methods that this content generator should support.
Default is GET, HEAD and POST for simple form controller types; unrestricted for general controllers and interceptors.
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.
Set whether to use the HTTP 1.1 cache-control header value "no-store" when preventing caching. Default is "true".
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.
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).
response | the current HTTP response |
---|---|
seconds | the (positive) number of seconds into the future that the response should be cacheable for; 0 to prevent caching; and a negative value to leave caching to the client. |
mustRevalidate | whether the client should revalidate the resource (typically only necessary for controllers with last-modified support) |
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.
response | current HTTP response |
---|---|
seconds | positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching |
Set HTTP headers to allow caching for the given number of seconds.
Tells the browser to revalidate the resource if mustRevalidate is
true
.
response | the current HTTP response |
---|---|
seconds | number of seconds into the future that the response should be cacheable for |
mustRevalidate | whether the client should revalidate the resource (typically only necessary for controllers with last-modified support) |
Set HTTP headers to allow caching for the given number of seconds. Does not tell the browser to revalidate the resource.
response | current HTTP response |
---|---|
seconds | number of seconds into the future that the response should be cacheable for |
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.
request | current HTTP request |
---|---|
response | current HTTP response |
cacheSeconds | positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching |
lastModified | if the mapped handler provides Last-Modified support |
ServletException | if the request cannot be handled because a check failed |
---|
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.
request | current HTTP request |
---|---|
response | current HTTP response |
lastModified | if the mapped handler provides Last-Modified support |
ServletException | if the request cannot be handled because a check failed |
---|
Prevent the response from being cached.
See http://www.mnot.net/cache_docs
.