JavaThinking.com
Toggle Menu
Home
Online Kotlin Compiler
Tutorials
Spring Boot
Spring Cloud
Spring Data
Spring MVC
Spring Security
Blog
All Posts
Spring MVC Fundamentals
Check your understanding of controllers,views,and request mapping.
1. Which component acts as the front controller in Spring MVC?
DispatcherServlet
FrontController
ControllerServlet
RequestHandler
2. What is the primary purpose of the @Controller annotation in Spring MVC?
Marks a class as a service bean
Marks a class as a controller to handle requests
Resolves view names to actual views
Manages database transactions
3. The @RequestMapping annotation can only be applied at the method level in Spring MVC.
True
False
4. Which annotations are used to map specific HTTP request methods in Spring MVC? (Select all that apply)
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
@RequestMethod
5. What is the role of @RequestParam in Spring MVC?
Extracts values from URI template variables
Binds request parameters to method parameters
Marks a method as a request handler
Resolves view names to JSP files
6. Name the annotation used to bind a request parameter to a model object (full name)
7. @ResponseBody causes a controller method's return value to be written directly to the response body without a view.
True
False
8. Which are core components of the Spring MVC request processing flow? (Select all that apply)
DispatcherServlet
HandlerMapping
Controller
ViewResolver
EntityManager
9. What is the default HTTP method for @RequestMapping if not explicitly specified?
GET
POST
PUT
DELETE
10. What annotation is used to map a controller method to handle GET requests (full name)
11. Spring MVC controllers must implement the Controller interface.
True
False
12. Which interface resolves logical view names to actual view objects?
View
ViewResolver
Model
HandlerAdapter
13. Which are valid return types for a Spring MVC controller method? (Select all that apply)
String (view name)
ModelAndView
void (with @ResponseBody)
@ResponseBody String
HttpServletResponse
14. What component maps incoming requests to the appropriate controller handler method?
15. What is the primary role of the Model interface in Spring MVC?
Resolves view names
Handles HTTP requests
Stores data for the view
Manages database connections
16. Which annotations can be applied at the class level in Spring MVC? (Select all that apply)
@Controller
@RestController
@RequestMapping
@GetMapping
@ModelAttribute
17. What does @PathVariable extract from the request URL?
Query parameters
URI template variables
Request headers
Session attributes
18. Which annotation is used to return data directly in the response body?
@Response
@ResponseBody
@View
@Direct
19. What is the purpose of @SessionAttributes in Spring MVC?
Extracts session parameters
Stores model attributes in the HTTP session
Invalidates the session
Maps session IDs to requests
20. Which view resolver is commonly used to resolve JSP views?
BeanNameViewResolver
InternalResourceViewResolver
XmlViewResolver
ResourceBundleViewResolver
Reset
Answered 0 of 0 — 0 correct