Which of the following annotations can be used to customize the response body in a Spring Boot application?
- @RequestBody
- @RequestMapping
- @ResponseBody
- @RestController
The @ResponseBody annotation in Spring Boot is used to customize the response body of a controller method. It allows you to return data in various formats, such as JSON, XML, or plain text, depending on the media type specified. This annotation is commonly used in RESTful API development to control the format of the response data.
Loading...
Related Quiz
- You have a Spring Boot application that integrates with several external services. How would you structure your tests to ensure that the interactions with external services are correctly handled, without actually interacting with the real services during the tests?
- The _____ annotation is used to mark the main class of a Spring Boot application.
- To define a global default exception handler for unhandled exceptions in Spring Boot, you can use a _____ with the highest precedence.
- How can you create a custom query method in a Spring Data JPA repository?
- When unit testing Spring Boot applications, how can you mock the behavior of methods in a class?