Spring @ResponseBody Annotation Example
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnht3YScK7rgrjfm1x46tZGqnBuejm-ZpyFJa3snLxD3bEaKsXdCmVhSqx-QgyZKu_wOIbdub3DBy1_44qsgBdKFfDqQtDNumZ3F4EpGMl0ph9pczdsxPr2Ddjb6OooV9KUBzG-PXnh0fXep3thqUNHShpDVTDxshYd7HxFqvghmyx9jHWabA7mJi04w/w400-h156/Untitled%20Diagram.drawio%20(6).png)
In this section we will learn about @ ResponseBody Annotation. @ ResponseBody is a Spring annotation which binds a method return value to the web response body. It is not interpreted as a view name. It uses HTTP Message converters to convert the return value to HTTP response body, based on the content-type in the request HTTP header. The @ResponseBody annotation is used at method level or method return type level. The @ResponseBody constructs the response body as JSON or XML or other media type based on following points. 1. MessageConverter configured in the application. 2. Media-type configured by produces attribute in annotations @RequestMapping , @GetMapping etc. 3. Media-type configured by accept request header. The @ResponseBody only configures body of response. To set response status code we use @ResponseStatus annotation at method level. If status code is not set explicitly, default status code is set to response. The @ResponseBody is used with @Controller anno