Spring Boot in Motion Spring Boot Intermediate

One HTTP request: from socket to @GetMapping

The request has a lifecycle — know it cold

A Spring Boot HTTP request is not magic; it is an ordered sequence of well-named responsibilities. Memorize the order. Everything else in this course — security, validation, data access, testing — plugs into a specific step of this pipeline.

  1. Tomcat (embedded) accepts the TCP connection and parses the HTTP request.
  2. Servlet filters run in configured order (security, CORS, request logging, etc.).
  3. DispatcherServlet consults HandlerMapping to find the controller method.
  4. HandlerInterceptors fire (pre-handle).
  5. Arguments are resolved by HandlerMethodArgumentResolvers (path vars, JSON body, headers).
  6. Your controller method runs. It returns a value or throws.
  7. The return value is converted to an HTTP body via HttpMessageConverters.
  8. Interceptors' post-handle and after-completion fire; filters wind back out in reverse order.
@RestController
@RequestMapping("/api/invoices")
class InvoiceController {

    private final InvoiceService service;

    InvoiceController(InvoiceService service) { this.service = service; }

    @GetMapping("/{id}")
    InvoiceDto get(@PathVariable long id) {
        return service.load(id).toDto();
    }
}

Open interactive lab →

Takeaways

  • Every request walks the same pipeline; know the order.
  • Controllers are edges — translate HTTP to domain calls and back.
  • Cross-cutting concerns belong in filters/interceptors, not controllers.

Enjoying This Lesson?

Your support helps create more comprehensive courses and lessons like this one. Help me build better learning experiences for everyone.

Support Awashyak