Tnadev
Tnadev

Reputation: 10082

What is flow of Spring MVC application

I am very new to Spring MVC. I have read a lot about it,but cant grab the exact flow of Application written in Spring MVC. Please if possible give me a highlevel view of flow of the application, may be with example of login application.

There are files like

Web.xml- According to my findings this file configures dispatcher
dispatcher-servlet - this file consist bean tags for dispatching the request to particular controller.
ApplicationContext.xml- I cant understand working of this file.

What exactly is difference of normal java Application and Spring MVC application.

Upvotes: 1

Views: 2367

Answers (2)

Ajay Takur
Ajay Takur

Reputation: 6236

  1. The browser gives request to web application.
  2. As frontcontroller DispatcherServlet traps and takes the request and applies the common system services like security,logging etc.,
  3. DispatcherServlet uses HandlerMapping component to decide the Handler class to utilize based on the incoming request uri.
  4. DispatcherServlet passes the control to Handler class by calling method.
  5. Handler class internally writes the received form data to command class object.
  6. Handler class process the request and generates the output, if needed it also uses command object work with form data.Sometimes handler class deligates the request to other external components like ejc,webservices and etc.,
  7. Handler class returns logical view name back to DispatcherServlet.
  8. DispatcherServlet uses view Resolver to get view object having view layer technology and resource name.
  9. DispatcherServlet uses the view object to pass the control to view resource.
  10. The view resource format the results and sends the output to browser(response to browser).

Upvotes: 0

Tnadev
Tnadev

Reputation: 10082

After reading some tutorials I understood what Spring MVC is. When any Web Application starts,it first loads welcome page,may be index.jsp which will redirect me to the start page(may be login) from a folder under /webcontent/Web-INF/jsp. Now the login request will be given to Dispatcher-servlet.xml whihc will find out the appropriate controller from the bean defination and handover control to login_controller where we might carryout userid and password check. And as per the condition we get either successView or FormView(i.e login page). We use ParametirazableViewController to display the static content on the page.

PS: I have considered a normal login example.

Upvotes: 2

Related Questions