Monday, 5 March 2018

@Controller vs. @RestController


@Controller defines a Spring controller, which is not necessarily returning a HTTP response. You must use @ResponseBody to indicate the HTTP response.

@RestController annotations are used to define the APIs to be exposed over HTTP(s) and returns a HTTP response.
So, implicitly it is equals to defining 2 annotations.
@RestController = @Controller + @ResponseBody

No comments:

Post a Comment

Note: only a member of this blog may post a comment.