@RestController
Learn @RestController (Controllers, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Fresher Notes REST controller is a Spring bean that handles HTTP requests and writes the return value straight into the response body (usually JSON) instead of rendering a view. Declare it with @RestController and map methods with @GetMapping , @PostMapping and friends. Return values are converted by an HttpMessageConverter , normally Jackson for JSON.
More lessons in Controllers
- @Controller
- Controller Lifecycle
- Controller Methods
- Request Mapping
- @RequestMapping
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
- Mapping HTTP Methods
- Mapping URL Paths
- Class-Level Mapping
- Method-Level Mapping
- Multiple URL Mappings
- Consumes
- Produces
- Mini Project: Controller Types and Mapping Rules