controller (Spring)

A Spring class, usually marked @RestController, whose methods handle HTTP requests for particular paths and return response bodies.

In more detail

A controller is the boundary between HTTP and application code: it reads transport data, calls a service and chooses a status and response model. Business decisions belong in the service so they can be reused and tested without a web server. Keep controllers thin enough that the request and response contract is visible in one place.

Example

@RestController public class OrderController { @GetMapping("/orders") String list() { ... } }

Related terms

Taught in

References