Skip to content

Spring MVC strategy interfaces

Spring MVC strategy interfaces refer to the specific extension points provided by the DispatcherServlet that define the workflow of request processing within the Spring MVC framework^[600-developer__java__spring__DispatcherServlet.md].

The DispatcherServlet acts as the front controller, but it delegates specific tasks—such as mapping requests to handlers, rendering views, and resolving locales—to these underlying strategy interfaces^[600-developer__java__spring__DispatcherServlet.md]. This architecture allows developers to customize individual parts of the request processing lifecycle by providing their own implementations of these strategies.

Core Strategies

The configuration of DispatcherServlet is primarily composed of the following strategy interfaces^[600-developer__java__spring__DispatcherServlet.md]:

  • HandlerMapping: Determines which controller (handler) should process the incoming request.
    • Common implementations include BeanNameUrlHandlerMapping and RequestMappingHandlerMapping^[600-developer__java__spring__DispatcherServlet.md].
  • HandlerAdapter: Enables the DispatcherServlet to invoke the handler regardless of the actual handler type (e.g., Controllers, HttpRequestHandler).
    • Specific adapters include HttpRequestHandlerAdapter, SimpleControllerHandlerAdapter, and RequestMappingHandlerAdapter^[600-developer__java__spring__DispatcherServlet.md].
  • ViewResolver: Resolves logical view names (Strings) returned by controllers into actual View objects.
    • A standard example is InternalResourceViewResolver^[600-developer__java__spring__DispatcherServlet.md].
  • HandlerExceptionResolver: Determines how to handle exceptions thrown during request processing.
    • Implementations include ExceptionHandlerExceptionResolver, ResponseStatusExceptionResolver, and DefaultHandlerExceptionResolver^[600-developer__java__spring__DispatcherServlet.md].
  • View: Represents the actual rendering of the user interface, often managed by a DefaultRequestToViewNameTranslator^[600-developer__java__spring__DispatcherServlet.md].

Sources

  • 600-developer__java__spring__DispatcherServlet.md