Why: A form backing object is a plain Java object. Spring fills its fields with the values submitted from the form.
2. How does Spring's implicit data binding decide which form value goes to which field of the backing object?
Why: Spring matches each form field name with the object field that has the same name and copies the value into it.
3. Which HTTP method is normally used to submit a form that sends data to the server for processing?
Why: A form that sends data to be processed is normally submitted with the POST method. The data goes in the request body.
4. A controller needs to show an empty form and also handle the form submission on the same URL. What is a common way to do this?
Why: A GET handler method returns the empty form. A POST handler method receives the submitted data. Both can use the same URL.
5. Is @ModelAttribute required on a handler method parameter to bind form data to a Java object?
Why: When a handler method has a Java object parameter, Spring binds matching request values to it implicitly. @ModelAttribute is not required.
6. Which annotation maps a handler method to HTTP POST requests in a short way?
Why:@PostMapping is the short form for mapping a handler method to HTTP POST requests.
7. An HTML input field has the name city. Which property of the backing object receives its value?
Why: Spring uses the field name to find the object property. A field named city is bound to the property named city.
8. What does the action attribute of an HTML <form> tag specify?
Why: The action attribute is the URL that receives the submitted data. The method attribute sets the HTTP method.
9. A handler method returns the String "registration-done". What does this String usually mean in Spring MVC?
Why: By default, a String returned from a controller handler method is a logical view name. A view resolver turns it into an actual page.
10. When a backing object is bound implicitly, under what default name is it added to the model?
Why: Spring adds the object to the model using its class name with a lowercase first letter. For example, a class named Employee becomes employee. The view can then use this name to show the data.
11. Which annotation marks a class as a Spring MVC controller that handles web requests?
Why:@Controller marks a class as a Spring MVC controller. Its handler methods can then handle web requests.
12. In a form submitted with POST, how does the form data reach the server?
Why: The browser sends the form data as name and value pairs, one for each field. Spring then uses these names to bind the values to the backing object.