Introduction to Spring MVC Framework

Introduction to spring mvc framework

Introduction to Spring MVC framework

We understand what MVC design pattern is, it will be easy to understand spring MVC framework. Spring Web MVC framework is basically designed to provide support for web architecture to develop enterprise level application with minimum efforts on initial web architecture. Spring MVC is designed around two components DispatcherServlet and @Component annotation. DispatcherServlet is basically centralized dispatcher which redirects any requests coming to the appropriate Spring Framework handlers. @Controller annotation is default handler for request and response. A Controller is basically a handler which handles user requests and response. It is responsible to prepare a data Model which can be used by the view. Means it prepares a Model Map with some.

Let’s understand the working of Spring MVC framework

  1. User enters some URL in browser to make some request to server.
  2. Request goes to DispatcherServlet which actually is front controller. DispatcherServlet is configured in web.xml. DispatcherServlet reads the request mappings in configuration file or annotated Controller list with help of Handler Adapter and dispatch it to the appropriate controller. Handler mappings map the request to appropriate controller.
  3. A Controller then reads the client request and process the request with the help of Business Logic defined in controller method. After processing the request, controller prepares the ModelAndView object.
  4. This ModelAndView object is then passed back to the front controller. Based on value passed in ModelAndView controller resolves the view that can be JSP file or some template configured.
  5. Based on the input, View is rendered and passed back to the user screen.

Take a look on flow diagram

Introduction to spring mvc framework
Introduction to spring mvc framework

Related Post

One thought on “Introduction to Spring MVC Framework”

Leave a Reply

Your email address will not be published. Required fields are marked *