Spring Boot - Spring AnnotationsWhich annotation should you use to mark a class that handles HTTP requests in a Spring Boot application?A@RepositoryB@ServiceC@ControllerD@ComponentCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall the role of each annotation@Controller is specifically designed for classes that handle web requests and return views or data.Step 2: Match the annotation to the web controller roleSince the question asks about handling HTTP requests, @Controller is the correct annotation.Final Answer:@Controller -> Option CQuick Check:Web request handler = @Controller [OK]Quick Trick: Web controllers use @Controller annotation [OK]Common Mistakes:Using @Service for web controllersConfusing @Repository with @ControllerUsing @Component instead of @Controller for HTTP handling
Master "Spring Annotations" in Spring Boot9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Spring Boot Quizzes Exception Handling - Why centralized error handling matters - Quiz 4medium Exception Handling - @ExceptionHandler in controllers - Quiz 9hard Inversion of Control and Dependency Injection - @Autowired for dependency injection - Quiz 4medium Logging - Package-level log configuration - Quiz 4medium REST Controllers - ResponseEntity for full response control - Quiz 15hard REST Controllers - @PostMapping for POST requests - Quiz 4medium Request and Response Handling - Why understanding request flow matters - Quiz 14medium Request and Response Handling - Returning different status codes - Quiz 5medium Request and Response Handling - Request mapping by method and path - Quiz 15hard Spring Boot Fundamentals - What is Spring Boot - Quiz 8hard