0 votes
1 view
in Java by (4.1k points)
Difference between spring @Controller and @RestController annotation.

Can @Controller annotation be used for both Web MVC and REST applications?

If yes, how can we differentiate if it is Web MVC or REST application?

1 Answer

0 votes
by (46.1k points)
  • @Controller is applied to point classes as Spring MVC Controller.
  • @RestController is a support annotation that does nothing more extra than combining the @Controller and @ResponseBody footnotes check: Javadoc

So the resulting two-controller definitions should do the likewise



public class MyController { }


public class MyRestController { }

Welcome to Intellipaat Community. Get your technical queries answered by top developers !