org.springframework.web.servlet.mvc
Class WebContentInterceptor

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.support.WebContentGenerator
              extended byorg.springframework.web.servlet.mvc.WebContentInterceptor
All Implemented Interfaces:
ApplicationContextAware, HandlerInterceptor

public class WebContentInterceptor
extends WebContentGenerator
implements HandlerInterceptor

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.

Since:
27.11.2003
Author:
Juergen Hoeller
See Also:
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.
 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.
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebContentInterceptor

public WebContentInterceptor()
Method Detail

preHandle

public boolean preHandle(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         java.lang.Object handler)
                  throws javax.servlet.ServletException
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler. Called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler.

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.

Specified by:
preHandle in interface HandlerInterceptor
Parameters:
request - current HTTP request
response - current HTTP response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
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.
Throws:
javax.servlet.ServletException

postHandle

public void postHandle(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       java.lang.Object handler,
                       ModelAndView modelAndView)
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler. Called after HandlerAdapter actually invoked the handler, but before the DispatcherServlet renders the view. Can expose additional model objects to the view via the given ModelAndView.

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.

Specified by:
postHandle in interface HandlerInterceptor
Parameters:
request - current HTTP request
response - current HTTP response
handler - chosen handler to execute, for type and/or instance examination
modelAndView - the ModelAndView that the handler returned, can also be null

afterCompletion

public void afterCompletion(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            java.lang.Object handler,
                            java.lang.Exception ex)
Description copied from interface: HandlerInterceptor
Callback after completion of request processing, i.e. after rendering the view. Will be called on any outcome of handler execution, thus allows for proper resource cleanup.

Note: Will only be called if this interceptor's preHandle method has successfully completed and returned true!

Specified by:
afterCompletion in interface HandlerInterceptor
Parameters:
request - current HTTP request
response - current HTTP response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution


Copyright (C) 2003-2004 The Spring Framework Project.