Controllers in detail
Controllers, with their methods annotated with @RequestMapping
, handle web requests. They accept input data in multiple forms and transform them into Model
attributes to be consumed by views that are displayed back to the client. They connect the user to service-layer beans, where your application behavior is defined.
A Controller in Spring MVC has the following signature:
public interface Controller { ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception; }
A Controller is designed as an interface, allowing you to create any kind of implementation. Starting from Spring version 2.5, you can turn any class into a Controller just by annotating it with @Controller
. It relieves you ...
Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.