NOTE
Using Spring MVC
Controller mappings, request binding, validation, JSON responses, exception handling, and safe web-layer boundaries.
This is a historical learning note and may contain outdated or incomplete understanding.
Use controllers to translate HTTP requests into application/service calls and translate results/errors back into HTTP responses.
Typical features include route annotations, path/query/header/body binding, bean validation, message conversion (for example JSON), response status/headers, and centralized exception handling.
Keep controllers thin: authentication/authorization policy, domain consistency, and persistence should not be hidden in parameter-binding code. Validate untrusted input and define stable external DTO/error contracts rather than exposing persistence/domain objects accidentally.