5 Dec 2017

Explain complete Spring MVC flow.

Explanation regarding Spring MVC flow is asked during interview most of time to experience as well as fresher .so here is the complete Spring MVC flow by which you can easily crack the interview.

Spring MVC Flow

1.   Browser gives request to Spring MVC Web Application.
2.   Dispatcher Servlet (sometimes called Front controller ) takes and traps the request & applies the Common System Services like Security, Logging, and Auditing.
3.   Dispatcher Servlet delegates the request to Handler Mapping.
4.   Once handler mapping gets the request maps the request with Handler Class/Controller class and returns the Handler  Class Bean Id. Now dispatcher servlet receives the bean id and somehow gets the handler class object and calls method of that object so that control goes to handler class.
5.   Handler class/Controller class creates command class object and perform request wrapping .i.e. receives the form data and stores (also called request wrapping) into Command Class object. Actually command class is java bean whose object holds received  the form data.( if there is form data).
6.   Now handler class executes its own business logic or talks with Service or DAO class get the output by processing the request.
7.   Now handler class returns Logical View Name to dispatcher servlet.
8.   Now dispatcher servlet take the Logical view name and returns View Interface Implementation Class Object having Physical View .it means dispatcher servlet uses View Resolver to get View Object having view layer technology and resource.
9.   Dispatcher servlet calls Render () method on that object.
10.     Now Render () method , transfer the control to View Resource for getting physical view like JSP, html etc.

11.      JSP contains the presentation logic and format the result and send formatted result to browser as response.