0 votes
1 view
in Java by (3.5k 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 (41k 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

@Controller

@ResponseBody

public class MyController { }

@RestController

public class MyRestController { }

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


Categories

...