@ResponseBody tells Spring MVC to send a controller action’s return value directly in the HTTP response, rather than treating it as a view name. section 10.2 section 10.6
Listing 10.1 Implementing a REST endpoint action in a controller class
@Controller #A
public class HelloController {
@GetMapping("/hello") #B
@ResponseBody #C
public String hello() {
return "Hello!";
}
}Here, the /hello action returns “Hello!” as the response body. section 10.2
For controllers with several REST actions, repeating the annotation can be avoided by using @RestController, which combines @Controller and @ResponseBody. section 10.2
