The controller controls the presentation layer logic. For all the business code, transactional use cases, persistence, etc., it typically delegates to a service layer.
A typical way of doing that is to implement transactional services as spring beans and inject those spring beans in controllers. Typical use case: create a new product:
- The controller receives a command bean from the browser
- It validates that all the required data is present, and if not, redisplays the product creation page with error messages
- It calls a service bean to create the product
- The service bean runs in a transaction. It gets the product category from the database, attaches the product to its category, computes the price for the product based on current pricing strategies, sends a JMS message to an external application, and returns the ID of the created product
- The controller redirects to the product detail page, using the ID of the created product as a URL parameter.