|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.support.WebContentGenerator org.springframework.web.servlet.mvc.WebContentInterceptor
Interceptor that checks and prepares request and response. Checks for supported methods and a required session, and applies the specified number of cache seconds. See superclass bean properties for configuration options.
All the settings supported by this interceptor can also be set on AbstractController. This interceptor is mainly intended for applying checks and preparations to a set of controllers mapped by a HandlerMapping.
AbstractController
Field Summary |
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator |
HEADER_CACHE_CONTROL, HEADER_EXPIRES, HEADER_PRAGMA, METHOD_GET, METHOD_POST |
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
Constructor Summary | |
WebContentInterceptor()
|
Method Summary | |
void |
afterCompletion(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object handler,
java.lang.Exception ex)
Callback after completion of request processing, i.e. after rendering the view. |
protected java.lang.Integer |
lookupCacheSeconds(java.lang.String urlPath)
Look up a cache seconds value for the given URL path. |
void |
postHandle(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object handler,
ModelAndView modelAndView)
Intercept the execution of a handler. |
boolean |
preHandle(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object handler)
Intercept the execution of a handler. |
void |
setAlwaysUseFullPath(boolean alwaysUseFullPath)
Set if URL lookup should always use full path within current servlet context. |
void |
setCacheMappings(java.util.Properties cacheMappings)
Map specific URL paths to specific cache seconds. |
void |
setUrlDecode(boolean urlDecode)
Set if context path and request URI should be URL-decoded. |
void |
setUrlPathHelper(UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use for resolution of lookup paths. |
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator |
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader |
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 |
Constructor Detail |
public WebContentInterceptor()
Method Detail |
public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
Only relevant for the "cacheMappings" setting.
setCacheMappings(java.util.Properties)
,
UrlPathHelper.setAlwaysUseFullPath(boolean)
public void setUrlDecode(boolean urlDecode)
Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).
Note: Setting this to true requires J2SE 1.4, as J2SE 1.3's URLDecoder class does not offer a way to specify the encoding.
Only relevant for the "cacheMappings" setting.
setCacheMappings(java.util.Properties)
,
UrlPathHelper.setUrlDecode(boolean)
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
Use this to override the default UrlPathHelper with a custom subclass, or to share common UrlPathHelper settings across multiple HandlerMappings and MethodNameResolvers.
Only relevant for the "cacheMappings" setting.
setCacheMappings(java.util.Properties)
,
AbstractUrlHandlerMapping.setUrlPathHelper(org.springframework.web.util.UrlPathHelper)
,
AbstractUrlMethodNameResolver.setUrlPathHelper(org.springframework.web.util.UrlPathHelper)
public void setCacheMappings(java.util.Properties cacheMappings)
Overrides the default cache seconds setting of this interceptor. Can specify "-1" to exclude an URL path from default caching.
cacheMappings
- a mapping between URL paths (as keys) and
cache seconds (as values, need to be integer-parsable)WebContentGenerator.setCacheSeconds(int)
public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler) throws javax.servlet.ServletException
HandlerInterceptor
DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically sending a HTTP error or writing a custom response.
preHandle
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- chosen handler to execute, for type and/or instance evaluation
true
if the execution chain should proceed with the
next interceptor respectively the handler itself. Else, DispatcherServlet
assumes that this interceptor has already dealt with the response itself.
javax.servlet.ServletException
protected java.lang.Integer lookupCacheSeconds(java.lang.String urlPath)
Supports direct matches, e.g. a registered "/test" matches "/test", and various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the PathMatcher class.
urlPath
- URL the bean is mapped to
PathMatcher
public void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, ModelAndView modelAndView)
HandlerInterceptor
DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can post-process an execution, getting applied in inverse order of the execution chain.
postHandle
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- chosen handler to execute, for type and/or instance examinationmodelAndView
- the ModelAndView that the handler returned, can also be nullpublic void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
HandlerInterceptor
Note: Will only be called if this interceptor's preHandle method has successfully completed and returned true!
afterCompletion
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- chosen handler to execute, for type and/or instance examinationex
- exception thrown on handler execution
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |