1. What is the main purpose of the DispatcherServlet.properties file in Spring MVC?
Why:DispatcherServlet.properties provides a fallback list of default strategy objects (such as HandlerMapping, HandlerAdapter, ViewResolver) that DispatcherServlet uses during initialization when no matching custom beans are found in the application context.
2. Where is the DispatcherServlet.properties file located?
Why: The file is placed at the same location as DispatcherServlet.java inside the Spring framework library, so it is available on the classpath without any extra configuration.
3. When does DispatcherServlet load the DispatcherServlet.properties file?
Why:DispatcherServlet loads these properties during initialization, specifically when it initializes its strategies (in the initStrategies() method), before handling any requests.
4. What happens if an application registers its own HandlerMapping bean?
Why:DispatcherServlet first checks whether a strategy bean has already been registered. If a custom HandlerMapping bean exists, it uses that bean and does not fall back to the default listed in DispatcherServlet.properties.
5. Which statement best describes the role of the DispatcherServlet.properties file?
Why: The file is explicitly described as a fallback: it is used only when no matching beans are found in the DispatcherServlet context. Developers are not expected to customize this file directly.
6. Which of the following strategy interfaces is not listed in DispatcherServlet.properties?
Why:DispatcherServlet.properties contains default implementations for HandlerMapping, HandlerAdapter, HandlerExceptionResolver, ViewResolver, LocaleResolver, FlashMapManager, and other strategy interfaces, but ControllerAdvice is not a strategy interface defined in this file.
7. What is the default implementation for the ViewResolver strategy according to DispatcherServlet.properties?
Why:DispatcherServlet.properties lists InternalResourceViewResolver as the default ViewResolver, which is typically used for JSP views.
8. Which default LocaleResolver is specified in DispatcherServlet.properties?
Why: The default LocaleResolver listed is AcceptHeaderLocaleResolver, which determines the locale from the HTTP Accept-Language header.
9. In the context of DispatcherServlet.properties, which interface is responsible for mapping incoming HTTP requests to handler objects?
// Which strategy interface has default implementations such as
// RequestMappingHandlerMapping and BeanNameUrlHandlerMapping?
org.springframework.web.servlet.________
Why:HandlerMapping is the strategy interface that maps requests to handlers. Its default implementations in DispatcherServlet.properties include RequestMappingHandlerMapping and BeanNameUrlHandlerMapping.
10. Which strategy interface is responsible for invoking the matched handler and is represented by default implementations like RequestMappingHandlerAdapter?
// Which strategy interface has default implementations such as
// RequestMappingHandlerAdapter and SimpleControllerHandlerAdapter?
org.springframework.web.servlet.________
Why:HandlerAdapter is the strategy interface used to invoke the handler that was selected by a HandlerMapping. The default implementations listed in DispatcherServlet.properties include RequestMappingHandlerAdapter and SimpleControllerHandlerAdapter.
11. What does DispatcherServlet do if no custom HandlerExceptionResolver bean is registered?
Why: If no custom HandlerExceptionResolver bean is found, DispatcherServlet falls back to the default implementations provided in DispatcherServlet.properties, such as ExceptionHandlerExceptionResolver, ResponseStatusExceptionResolver, and DefaultHandlerExceptionResolver.
12. Which of the following is the default RequestToViewNameTranslator implementation in DispatcherServlet.properties?
Why:DispatcherServlet.properties specifies DefaultRequestToViewNameTranslator as the default implementation for the RequestToViewNameTranslator strategy, which derives a view name from the request URL when the controller does not return one explicitly.
13. What is the default FlashMapManager implementation listed in DispatcherServlet.properties?
Why:SessionFlashMapManager is the default FlashMapManager implementation. It stores flash attributes in the HTTP session by default so they can survive redirects.
14. How should application developers treat the DispatcherServlet.properties file?
Why: The comments in the file explicitly state that it is not meant to be customized by application developers. It serves as a fallback that supplies default strategies only when no custom beans are registered.
15. Which mechanism can cause the default strategies in DispatcherServlet.properties to be bypassed?
Why: If an application registers a bean for a strategy interface (for example, a custom HandlerMapping or ViewResolver), DispatcherServlet will use that bean instead of the default implementation listed in DispatcherServlet.properties. Using @EnableWebMvc is another way to override the defaults.