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.
Loading...
Related Quiz
- In a Spring Boot application, how would you handle a scenario where different microservices need to work with different databases and schemas?
- Imagine you are dealing with a large Spring Boot application having numerous modules, each requiring different configuration properties. How would you organize and manage the configuration properties efficiently without any conflicts?
- What considerations should be taken into account when designing API endpoints using Request Mapping annotations in Spring Boot?
- In a Spring Boot application, the _____ annotation is used to bind the value of a method parameter to a named cookie value.
- When does the auto-configuration process occur in the lifecycle of a Spring Boot application?