In Spring MVC, a Controller is usually a Plain java class annotated with @Controller
, a View is anything that implements org.springframework.web.servlet.View
and the model is usually a ModelMap
, a specialized Map
implementation.
In a standard setup, a controller method usually returns either a String or a business object.
If it returns a String, that is interpreted as a path to the view name (JSP, Freemarker etc.). If it is a business object and the method is annotated with @ResponseBody
, then content negotiation starts, one of the key features of Spring MVC. Depending on configurable aspects like the Accept: header, the path extension etc. Spring automatically serializes the business object to JSON, XML, PDF etc.
The whole mechanism is explained in the Spring Reference under