Close
« Tutorial

Spring MVC - Customizing Formatters MCQ

0/13
0 ✓
0 ✗

1. What is the main job of a Formatter in Spring MVC?

2. Which feature was introduced in Spring 3 as a simple alternative to PropertyEditor classes?

3. You need general-purpose type conversion logic, for example converting a java.util.Date to a java.lang.Long. Which SPI should you use?

4. Which statement correctly describes the difference between a Converter and a Formatter?

5. What does the ConversionService provide in Spring?

6. Which annotation is used on a controller method to customize data binding for that controller?

7. Which object is passed to an @InitBinder method so that you can register a custom formatter?

8. Which method of WebDataBinder is used to register a formatter for a specific field name?

@InitBinder
public void customize(WebDataBinder binder) {
    binder.____(new DateFormatter("MM-dd-yyyy"), "startDate");
}

9. Which built-in Spring formatter is used to format and parse java.util.Date values?

10. Which built-in Spring formatter is used to show a number as money with a currency symbol, such as $?

11. What does NumberStyleFormatter do?

12. Which method of WebMvcConfigurer is used to register a formatter globally?

13. When is it a good idea to register a formatter globally?

14. What is an advantage of configuring formatters in an @InitBinder method compared to registering them globally?

15. A formatter is registered for a field. In a JSP page, a plain EL expression like ${object.field} does not show the formatted value. Which Spring tag can you use to show it?

16. What does a Formatter do with text that a user types into a form field?

Join