Spring MVC Architecture
Spring MVC Flow
- Spring MVC flow starts when user submits request from the browser.
- The request comes to DispatchServlet via web.xml.It automatically loads the spring configuration file whose name format is <servlet-name>-servlet.xml,where <servlet-name> is configured in web.xml file.
- The DispatchServlet consults Handler Mapping to decide controller class to delegate.
- The Handler Mapping decides one controller among many controllers based on URL path.
- The DispatchServlet delegates request to the corresponding Controller(UserController.java).
- The Controller returns ModelAndView,which contains logical view and model data ,back to DispatchServlet.
- The DispatchServlet consults a view resolver to resolve response view name including it’s location.
- The ViewResolver returns physical response view page name.
- Finally,the DispatchServlet does view navigation to response page.
The Spring MVC flow is almost same as Struts MVC webflow.The minor differences between spring and struts mvc flows are:
|Business Logic Class||subclass of Controller interface||subclass of Action class|
|FormBeans||No separate form bean||Have separate form bean|