Close

Spring MVC - @ModelAttribute on Handler Parameter MCQ

« Tutorial
0 of 0 answered ( ✔ 0 | ✘ 0 )

1. What does @ModelAttribute do when it is placed on a handler method parameter?

2. What does @ModelAttribute do when it is placed on a method (method level)?

3. When does Spring call the methods annotated with @ModelAttribute?

4. Which pair of steps lets a handler method receive a value that was prepared in the Model?

5. How does Spring find the object for a handler parameter annotated with @ModelAttribute("item")?

6. Which annotation tells Spring to get the value of the user parameter from the Model?

@RequestMapping("profile")
public String show (/* annotation here */ User user) {
    ...
}

7. What happens if Spring cannot find a matching named object in the Model for a @ModelAttribute parameter?

8. Where does Spring put the return value of a method annotated with @ModelAttribute?

9. An object is already in the Model and the view can use it. Why would we still add it as a @ModelAttribute parameter to a handler method?

10. What can be the return type of a method annotated with @ModelAttribute?

11. A controller class has the @SessionAttributes annotation. What does Spring check first for a @ModelAttribute handler parameter?

12. A controller uses @SessionAttributes and the named value is found in the HttpSession. What does Spring do with the related @ModelAttribute method?

13. Which use of @ModelAttribute adds attributes to the Model before the handler method is invoked?

Join