Spring MVC Architecture


Front Controller

This is the Dispatcher servlet controller also called as Front controller which is the main controller which manages the flow of the Spring MVC application.
This is defined in the web.xml as below

  1. <web-app>
  2.     <servlet>
  3.         <servlet-name>Dispatcher-Servlet</servlet-name>
  4.         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  5.         <load-on-startup>1</load-on-startup>
  6.     </servlet>
  8.     <servlet-mapping>
  9.         <servlet-name> Dispatcher-Servlet </servlet-name>
  10.         <url-pattern>/</url-pattern>
  11.     </servlet-mapping>
  13. </web-app>

        <servlet-name> Dispatcher-Servlet </servlet-name>


So Dispatcher servlet is defined and mapped to the url pattern /, which means all request must go through Dispatcher servlet.


Controller is the one which handles the specific request which is mapped by its request mapping.


  1. @Controller
  2. Public class A{
  3.           @RequestMapping(β€œ/login”)
  4.           Public void login(){
  5.                                       //do whatever you want
  6.                               }
  7.              }
Public class A{
          Public void login(){
                                      //do whatever you want

So every controller class will be annotated with @controller and each of its method is mapped to some request url.


Model is the class which holds the data to transfer between view and controller.
Anything in the view is transferred to controller using model class and vice versa.

View Template

View is the UI thing which is used for displaying the data,it can be jsp or any other view technology.
Specific view for the corresponding request is displayed based on the view resolver, it helps in finding the exact view name.

Steps to create spring mvc application

1) Define the dispatcher servlet in web.xml

2) Create spring configuration file and define the packages to scan for spring beans

3) Create a simple JSP page which will have a form request to be submitted.

4) Create the controller class which will have a method to map a particular request.

5) Create the model class which can hold the form data.

6) Define view resolver in spring configuration file

7) Create the view page(.jsp) to hold the response from the controller.

Flow of spring mvc application will be as below

1) User Makes a request through an URL

2) URL is passed to dispatcher servlet

3) Dispatcher servlet passes the request to the corresponding controller based on url mapping.

4) Controller performs the task and return the model and view.

5) Dispatcher servlet maps the view name to the corresponding jsp(any view technology) using view resolver.

6) View renders the model and display it.

About the Author

Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology πŸ™‚
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on