Bird
0
0

Which annotation should you use to mark a class that handles HTTP requests in a Spring Boot application?

easy📝 Syntax Q12 of 15
Spring Boot - Spring Annotations
Which annotation should you use to mark a class that handles HTTP requests in a Spring Boot application?
A@Repository
B@Service
C@Controller
D@Component
Step-by-Step Solution
Solution:
  1. Step 1: Recall the role of each annotation

    @Controller is specifically designed for classes that handle web requests and return views or data.
  2. Step 2: Match the annotation to the web controller role

    Since the question asks about handling HTTP requests, @Controller is the correct annotation.
  3. Final Answer:

    @Controller -> Option C
  4. Quick Check:

    Web request handler = @Controller [OK]
Quick Trick: Web controllers use @Controller annotation [OK]
Common Mistakes:
  • Using @Service for web controllers
  • Confusing @Repository with @Controller
  • Using @Component instead of @Controller for HTTP handling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes