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
BeanNameUrlHandlerMappingandRequestMappingHandlerMapping^[600-developer__java__spring__DispatcherServlet.md].
- Common implementations include
- HandlerAdapter: Enables the
DispatcherServletto invoke the handler regardless of the actual handler type (e.g., Controllers,HttpRequestHandler).- Specific adapters include
HttpRequestHandlerAdapter,SimpleControllerHandlerAdapter, andRequestMappingHandlerAdapter^[600-developer__java__spring__DispatcherServlet.md].
- Specific adapters include
- ViewResolver: Resolves logical view names (Strings) returned by controllers into actual View objects.
- A standard example is
InternalResourceViewResolver^[600-developer__java__spring__DispatcherServlet.md].
- A standard example is
- HandlerExceptionResolver: Determines how to handle exceptions thrown during request processing.
- Implementations include
ExceptionHandlerExceptionResolver,ResponseStatusExceptionResolver, andDefaultHandlerExceptionResolver^[600-developer__java__spring__DispatcherServlet.md].
- Implementations include
- View: Represents the actual rendering of the user interface, often managed by a
DefaultRequestToViewNameTranslator^[600-developer__java__spring__DispatcherServlet.md].
Related Concepts¶
- [[Spring MVC]]
- DispatcherServlet
- [[Front Controller pattern]]
Sources¶
600-developer__java__spring__DispatcherServlet.md