Hello folks, if you are preparing for Java and Spring Developer interview then you may have come across "difference between @Controller and @RestController annotation" in Spring Boot and Spring Framework in general. It's one of the popular spring question which I have also mentioned in my list of , and to return JSON or XML data, otherwise, the response will be treated as a view name and a view resolver will try to resolve it while @ResponseBody annotation is not necessary as it is already included in the annotation.
That's all about the difference between @Controller and @RestController annotation in Spring Boot. Just remember that @Controller is used to create web controllers that return views, which is further resolved by view resolver, while @RestController is used to create web services that return JSON or XML data. It's also worth noting.
SOCIAL SHARE CARD GENERATOR