Close
« Tutorial

Spring MVC - @SessionAttributes with @ModelAttribute MCQ

0/13
0 ✓
0 ✗

1. At which level is the @SessionAttributes annotation used?

2. What does the value element of @SessionAttributes contain?

3. What is the main purpose of @SessionAttributes?

4. A controller has @SessionAttributes("user") and a method annotated with @ModelAttribute("user"). When is this @ModelAttribute method called?

5. What happens to the value returned by a @ModelAttribute method when its name is listed in @SessionAttributes?

6. In the same HTTP session, an attribute is already stored by @SessionAttributes. What does Spring do on the next requests?

7. A handler method parameter is annotated with @ModelAttribute("user"), and the name is listed in @SessionAttributes. Where does Spring get the value for this parameter first?

8. Which exception is thrown when a handler needs a session attribute through @ModelAttribute, but it is not in the session and no @ModelAttribute method can create it?

9. How long does a session attribute stay in the HttpSession after being added through @SessionAttributes?

10. Which type can be used as a handler method parameter to remove @SessionAttributes attributes from the session?

11. Which method of SessionStatus is called to signal that session processing is complete?

12. What happens after SessionStatus.setComplete() is called?

13. A session attribute was removed by calling setComplete(). A later request in the same session needs that attribute again. What happens?

14. Which of these is a good use case for @SessionAttributes?

15. What do the names in @SessionAttributes need to match?

Join