Spring Interview questions - Day 1 โ#codecraftelugu #programming #coding #telugu #shorts #java
Ever wondered which annotation to use in your Spring Boot project? ๐ป Whether you're building a traditional web app or a modern REST API, understanding these two is crucial!
In this quick breakdown, we cover:
โ
@Controller: The go-to for Spring MVC (returning views like Thymeleaf/JSP).
โ
@RestController: The powerhouse for APIs (combines @Controller + @ResponseBody).
โ
The Key Difference: How they handle data vs. views.
๐ Key Takeaways:
โข Use @Controller when you want to return a view (HTML).
โข Use @RestController when you want to return data (JSON/XML) directly in the HTTP response body.
โข Pโฆ
Watch on YouTube โ
(saves to browser)
DeepCamp AI