Skip to main content

@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