Spring-MVC

Spring MVC Flow

  1. Spring MVC flow starts when user submits request from the browser.
  2. 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.
  3. The DispatchServlet consults Handler Mapping to decide controller class to delegate.
  4. The Handler Mapping decides one controller among many controllers based on URL path.
  5. The DispatchServlet delegates request to the corresponding Controller(UserController.java).
  6. The Controller returns ModelAndView,which contains logical view and model data ,back to DispatchServlet.
  7. The DispatchServlet consults a view resolver to resolve response view name including it’s location.
  8. The ViewResolver returns physical response view page name.
  9. 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:

Spring Struts
Front-controller DispatcherServlet ActionServlet
Business Logic Class subclass of Controller interface subclass of Action class
Return Type ModelAndView ActionForward
Method Name handleRequest() execute()
FormBeans No separate form bean Have separate form bean