Close

Spring MVC - @RequestMapping MCQ

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

1. What is the main purpose of the @RequestMapping annotation in Spring MVC?

2. Where can the @RequestMapping annotation be applied?

3. What happens if a controller class has @RequestMapping but a handler method inside it does not?

4. What does the method element of @RequestMapping specify?

5. How do you specify that a handler method should support both GET and DELETE HTTP methods using @RequestMapping?

@RequestMapping(value = "/{id}", /* add method element */)

6. What is the purpose of the params element in @RequestMapping?

7. Which @RequestMapping configuration will match any request that has a query parameter named dept, regardless of its value?

@RequestMapping(/* specify params element */)

8. What does the headers element of @RequestMapping do?

9. What does the consumes element of @RequestMapping specify?

10. What does the produces element of @RequestMapping specify?

11. What is the purpose of the path element in @RequestMapping?

12. How do you define a URI template variable {userId} in the path of a handler method?

@RequestMapping(/* specify value element */)

13. Which annotation is used to capture a URI template variable in a handler method parameter?

14. What does an empty @RequestMapping (without a path) on a method do?

15. What is the name element of @RequestMapping used for?

16. What is the version element introduced in Spring 7's @RequestMapping used for?

17. What is an Ant-style path pattern in the context of @RequestMapping?

18. How can you negate a media type in the consumes or produces element of @RequestMapping?

Join