Answer:
๐๐๐ฌ๐ฉ๐จ๐ง๐ฌ๐๐๐จ๐๐ฒ annotation is a step further from a classic MVC approach to a REST approach
when ๐๐ข๐๐ฐ๐๐๐ฌ๐จ๐ฅ๐ฏ๐๐ซ is not needed and request-handler result might be directly written to the http-response body.
๐๐๐ฌ๐ฉ๐จ๐ง๐ฌ๐๐๐จ๐๐ฒ annotation does exactly that, enabling functionality offered by ๐๐ญ๐ญ๐ฉ๐๐๐ฌ๐ฌ๐๐ ๐๐๐จ๐ง๐ฏ๐๐ซ๐ญ๐๐ซ message-converters.
Note: ๐๐๐ฌ๐ฉ๐จ๐ง๐ฌ๐๐๐จ๐๐ฒ annotation might be applied at a type level,
thus all handler methods declared within that type will inherit declared behavior.
The @ResponseBody annotation tells a controller that the object returned is automatically serialized into JSON and passed back into the HttpResponse object.
Suppose we have a custom Response object:
Next, the associated controller can be implemented:
In the developer console of our browser or using a tool like Postman, we can see the following response:
{"๐ญ๐๐ฑ๐ญ":"๐๐ก๐๐ง๐ค๐ฌ ๐ ๐จ๐ซ ๐๐จ๐ฌ๐ญ๐ข๐ง๐ !!!"}
Remember, we don't need to annotate the @RestController-annotated controllers with the @ResponseBody annotation since Spring does it by default.
#spring #certificationquestion #vcp
@ResponseBody ๐ https://www.baeldung.com/spring-request-response-body#requestbody