1. What is the main job of a WebBindingInitializer in Spring MVC?
Why: A WebBindingInitializer sets up a WebDataBinder for a request, so Spring knows how to convert, format and validate request data.
2. What is a WebDataBinder used for?
Why: A WebDataBinder takes request values, such as parameters, and binds them to Java types. It applies conversion, formatting and validation on the way.
3. What is ConfigurableWebBindingInitializer?
Why:ConfigurableWebBindingInitializer is a configurable implementation of WebBindingInitializer. You can set the conversion service, validator and property editor registrars on it.
4. Which Spring MVC component uses the ConfigurableWebBindingInitializer to apply data conversion, formatting and validation to requests?
Why:RequestMappingHandlerAdapter uses the ConfigurableWebBindingInitializer when it prepares data binding for controller method arguments.
5. What is the scope of a custom PropertyEditor that is registered through a ConfigurableWebBindingInitializer?
Why: An editor registered in the initializer is used for every data binding in the application. An @InitBinder method is different, because it is local to its own controller.
6. When might you remove @EnableWebMvc and extend WebMvcConfigurationSupport directly?
Why:WebMvcConfigurer covers most settings. For an advanced setting it does not expose, you can extend WebMvcConfigurationSupport and override its methods.
7. If a configuration class already extends WebMvcConfigurationSupport, is @EnableWebMvc needed?
Why:WebMvcConfigurationSupport is the base class that provides the default Spring MVC setup. Extending it directly replaces the need for @EnableWebMvc.
8. Which method of WebMvcConfigurationSupport can you override to customize the ConfigurableWebBindingInitializer?
Why: Override getConfigurableWebBindingInitializer() in a class that extends WebMvcConfigurationSupport to change how the initializer is created.
9. Why should you usually call the super version of the initializer method when you customize it?
Why: Calling the super method gives you the default initializer. You then customize it, instead of replacing it completely and losing the default behavior.
10. Which interface is used to register custom property editors in a ConfigurableWebBindingInitializer?
Why: A PropertyEditorRegistrar registers custom editors with a PropertyEditorRegistry. It is set on the initializer, so the editors are applied to every binder.
11. Which built-in Spring class is a PropertyEditor that converts text to java.util.Date using a given date format?
Why:CustomDateEditor is a built-in PropertyEditor. You give it a date format, and it converts request text to a Date.
12. A custom editor for the Date type is registered globally with the format yyyy-MM-dd. What happens when a request sends a date in a different format?
Why: If the editor cannot convert the request value, data binding fails. Spring MVC then returns a 400 Bad Request response.
13. When you register a custom editor for a type such as Date.class, when is that editor used?
Why: A custom editor is registered for a specific target type. Whenever binding needs to convert a request value to that type, the editor is used.
14. How is customizing a ConfigurableWebBindingInitializer different from replacing it completely?
Why: When you customize, you start from the default initializer and change only what you need. When you replace it, you are responsible for all of its settings.