类 AbstractController

  • 所有已实现的接口:
    Aware, ApplicationContextAware, ServletContextAware, Controller
    直接已知子类:
    AbstractUrlViewController, ParameterizableViewController, ServletForwardingController, ServletWrappingController

    public abstract class AbstractController
    extends WebContentGenerator
    implements Controller
    Convenient superclass for controller implementations, using the Template Method design pattern.

    Workflow (and that defined by interface):

    1. handleRequest() will be called by the DispatcherServlet
    2. Inspection of supported methods (ServletException if request method is not support)
    3. If session is required, try to get it (ServletException if not found)
    4. Set caching headers if needed according to the cacheSeconds property
    5. Call abstract method handleRequestInternal() (optionally synchronizing around the call on the HttpSession), which should be implemented by extending classes to provide actual functionality to return ModelAndView objects.

    Exposed configuration properties (and those defined by interface):

    namedefaultdescription
    supportedMethodsGET,POSTcomma-separated (CSV) list of methods supported by this controller, such as GET, POST and PUT
    requireSessionfalsewhether a session should be required for requests to be able to be handled by this controller. This ensures that derived controller can - without fear of null pointers - call request.getSession() to retrieve a session. If no session can be found while processing the request, a ServletException will be thrown
    cacheSeconds-1indicates the amount of seconds to include in the cache header for the response following on this request. 0 (zero) will include headers for no caching at all, -1 (the default) will not generate any headers and any positive number will generate headers that state the amount indicated as seconds to cache the content
    synchronizeOnSessionfalsewhether the call to handleRequestInternal should be synchronized around the HttpSession, to serialize invocations from the same client. No effect if there is no HttpSession.
    作者:
    Rod Johnson, Juergen Hoeller, Rossen Stoyanchev
    另请参阅:
    WebContentInterceptor