juniorSpring

What is a REST Controller in Spring?

Updated May 17, 2026

Short answer

@RestController is used to build REST APIs returning JSON responses.

Deep explanation

It combines @Controller and @ResponseBody. It automatically serializes return objects into JSON using Jackson.

Real-world example

Backend APIs for mobile apps.

Common mistakes

  • Using @Controller instead of @RestController for APIs.

Follow-up questions

  • What does @ResponseBody do?
  • Which library handles JSON conversion?

More Spring interview questions

View all →