DispatcherServlet.properties contains the list of default strategy objects/handlers used by the DispatcherServlet.
This file is located at the same location as DispatcherServlet.java :
Following are the contents from version 7.0.4:
# Default implementation classes for DispatcherServlet's strategy interfaces.
# Used as fallback when no matching beans are found in the DispatcherServlet context.
# Not meant to be customized by application developers.
org.springframework.web.servlet.LocaleResolver=org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
org.springframework.web.servlet.HandlerMapping=org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,\
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping,\
org.springframework.web.servlet.function.support.RouterFunctionMapping
org.springframework.web.servlet.HandlerAdapter=org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,\
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,\
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter,\
org.springframework.web.servlet.function.support.HandlerFunctionAdapter
org.springframework.web.servlet.HandlerExceptionResolver=org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver,\
org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver,\
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
org.springframework.web.servlet.RequestToViewNameTranslator=org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator
org.springframework.web.servlet.ViewResolver=org.springframework.web.servlet.view.InternalResourceViewResolver
org.springframework.web.servlet.FlashMapManager=org.springframework.web.servlet.support.SessionFlashMapManager
How DispatcherServlet.properties is used?
DispatcherServlet loads these properties during initialization.
The DispatcherServlet, during initializing different strategies (DispatcherServlet#initStrategies()), checks one by one if those strategies have already been registered; if not, it uses the strategy set by DispatcherServlet.properties. That means if we register different strategies bean in our application ( e.g HandlerMapping, HandlerAdapter etc) or by other means like by using @EnableWebMvc, the strategies listed in DispatcherServlet.properties, will not be used.
Quick Overview of DispatcherServlet Strategies
-
org.springframework.web.servlet.LocaleResolver → org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver Determines the current Locale for the request. The default implementation resolves the locale from the HTTP Accept-Language header sent by the client.
-
org.springframework.web.servlet.HandlerMapping → BeanNameUrlHandlerMapping, RequestMappingHandlerMapping, RouterFunctionMapping Maps incoming HTTP requests to handler objects:
BeanNameUrlHandlerMapping – Maps URLs to beans whose names match the URL.
RequestMappingHandlerMapping – Maps requests to @RequestMapping (and related) annotated controller methods.
RouterFunctionMapping – Maps functional routing definitions (RouterFunction API).
-
org.springframework.web.servlet.HandlerAdapter → HttpRequestHandlerAdapter, SimpleControllerHandlerAdapter, RequestMappingHandlerAdapter, HandlerFunctionAdapter Invokes the matched handler using the appropriate adapter:
HttpRequestHandlerAdapter – Supports handlers implementing HttpRequestHandler.
SimpleControllerHandlerAdapter – Supports legacy Controller interface implementations.
RequestMappingHandlerAdapter – Invokes @RequestMapping annotated methods with argument resolution and return value handling.
HandlerFunctionAdapter – Supports functional-style handler functions.
-
org.springframework.web.servlet.HandlerExceptionResolver → ExceptionHandlerExceptionResolver, ResponseStatusExceptionResolver, DefaultHandlerExceptionResolver Resolves exceptions thrown during handler execution:
ExceptionHandlerExceptionResolver – Handles exceptions via @ExceptionHandler methods.
ResponseStatusExceptionResolver – Maps exceptions annotated with @ResponseStatus to HTTP status codes.
DefaultHandlerExceptionResolver – Translates common Spring MVC exceptions into standard HTTP error responses.
-
org.springframework.web.servlet.RequestToViewNameTranslator → DefaultRequestToViewNameTranslator Derives a logical view name from the request URL when the controller does not explicitly return a view name.
-
org.springframework.web.servlet.ViewResolver → InternalResourceViewResolver Resolves logical view names to actual view resources (typically JSP files) within the web application.
-
org.springframework.web.servlet.FlashMapManager → SessionFlashMapManager Manages flash attributes (temporary attributes stored across redirects), using the HTTP session by default.
|
|