2V0-72-22 practice question 5 of 15
Which two statements are true about @Controller annotated classes? (Choose two.)
Full set: 79 questionsThe @Controller annotation is a specialization of the @Component annotation, making it a stereotype. This means that any class annotated with @Controller is eligible for component scanning and will be registered as a bean in the application context. Its primary role in Spring MVC is to mark a class as a web controller, making its methods eligible to handle incoming web requests when mapped with annotations like @RequestMapping.
A. @Controller classes can return data directly (e.g., JSON) by using the @ResponseBody annotation on a method, not just render views.
C. @EnableMvcMappings is not a standard Spring annotation. Component scanning, enabled by @ComponentScan or @SpringBootApplication, discovers @Controller beans.
D. @RestController is a composite annotation that includes @Controller and @ResponseBody. They are not interchangeable without code changes, as methods in a @Controller do not implicitly have @ResponseBody behavior.
1. Spring Framework Documentation, 6.1.6. "Web on Servlet Stack", Section 22.3.1. "Defining a Controller with @Controller". States that @Controller indicates that a class serves the role of a controller and is a stereotype for component scanning.
2. Javadoc for org.springframework.stereotype.Controller. The annotation's source code shows it is meta-annotated with @Component.
3. Spring Framework Documentation, 6.1.6. "Web on Servlet Stack", Section 22.3.4. "@RestController". Explains that @RestController is a convenience annotation that combines @Controller and @ResponseBody.
Keep practicing
Take the free 2V0-72-22 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 2V0-72-22 practice questions
- Question 1Which two statements describe Spring JdbcTemplate? (Choose two.)
- Question 2Which two options will inject the value of the daily.limit system property? (Choose two.)
- Question 3Which two statements are true regarding Spring and Spring Boot Testing? (Choose two.)
- Question 4Which two statements are correct regarding Spring Boot auto-configuration customization? …
- Question 6Which statement is true? (Choose the best
- Question 8Which two statements are correct regarding the Health Indicator status? (Choose two.)
