loading table of contents...

Content Application Developer Manual / Version 2310

Table Of Contents Post Processing the Model

Spring MVC includes a concept for preprocessing and post-processing a handler's execution. By implementing a HandlerInterceptor it is possible for example to modify the ModelAndView of all executed handlers.


import org.springframework.web.servlet.HandlerInterceptor;
public class MyInterceptor implements HandlerInterceptor {
  void postHandle(HttpServletRequest req, HttpServletResponse res,
            Object handler, ModelAndView modelAndView)
            throws Exception {
    // adds a new model object to the model and view
    modelAndView.addObject("message", "Hello World");

A custom interceptor can be associated with all handlers by adding the interceptor bean to a global list bean named handlerInterceptors that defined by the CAE framework. A customizer might be used here, for example

<customize:append id="addMyInterceptor" bean="handlerInterceptors">
    <bean class="com.mycompany.MyInterceptor"/>

See for more information about handler interceptors.

Search Results

Table Of Contents

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.