Thursday, July 8, 2010

spring-mvc-application-flow-with-diagram

I will explain ‘Flow of typical Spring MVC application’ or in other words ‘How exactly user gets served?’. We will see how data and control flows through all the stages of this process. Let me start with one diagram,

Spring2

Here’s the transition explanation below,

  • Transition 1 – User sends request to server by submitting form / by clicking hyperlink etc. Request is initially given to WEB.XML.
  • Transition 2 – WEB.XML routes request to DispatcherServlet by looking at tag.
  • Transition 3 – Inside DispatcherServlet, First ‘HandlerMapping’ handed over request to suitable ‘Controller’.
  • Transition 4 – Controller maps request to proper Model class. All BUSINESS LOGIC is done inside Model class.
  • Transition 5 – If database operation is needed then Model class will route request to suitable DAO. All database operations should be carried out in DAO.
  • Transition 6 – If needed then attach attributes into request/session/application scope and return back to Model.
  • Transition 7 – If needed then attach attributes into request/session/application scope and return back to Controller.
  • Transition 8 – Controller simply returns it to any View(JSP/HTML etc).
  • Transition 9 – JSP/Html is viewed back to user.

I will post related Spring MVC sample application soon.

No comments:

Post a Comment