Skip to main content

Web for Spring Boots

The Spring Boot web layer is where HTTP requests reach your code. It uses Spring MVC controllers annotated with @RestController, request mappings, validation and exception handlers to build REST APIs that return JSON. API documentation, commonly generated from OpenAPI, describes those endpoints so clients can consume them without reading the source.

Stage: Spring Core · Part of the Spring Boot roadmap · Last reviewed 19 November 2026

What to learn in Web

Web interview questions

What is the difference between @Controller and @RestController?

@RestController is @Controller plus @ResponseBody, so every method's return value is written straight to the HTTP response body, usually as JSON. A plain @Controller normally returns a view name for template rendering. Use @RestController when building APIs.

How do you handle exceptions globally in a Spring Boot API?

Create a class annotated with @RestControllerAdvice and add methods annotated with @ExceptionHandler for specific exception types. Each returns a response with a suitable status code and a structured body. This keeps controllers clean and gives clients predictable error formats.

Where Web fits in the Spring Boot roadmap

Web belongs to the Spring Core stage (beginner level), which takes about 28 hours. The container.

Back to the full Spring Boot roadmap