For a method in a @Controller annotated class in Spring Boot to write directly to the response body, it needs to be annotated with _____.

  • @ResponseBody
  • @RestController
  • @RequestMapping
  • @PathVariable
To make a method in a @Controller annotated class in Spring Boot write directly to the response body, you should use the @ResponseBody annotation. This annotation is used to indicate that the return value of the method should be serialized directly to the HTTP response body. The other options have different purposes, such as defining request mappings, specifying controller types, or handling path variables.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *