Spring MVC Architecture
Spring’s web MVC framework is, like many other web MVC Architecture frameworks, request-driven, designed around a central servlet that dispatches requests to controllers and offers other functionality that facilitates the development of web applications.
Spring’s DispatcherServlet is completely integrated with Spring IoC container and allows us to use every other feature of Spring.
Following is the Request process lifecycle of Spring MVC Architecture 3.0
The client sends a request to web container in the form of http request.
Also, This incoming request intercepted by the Front controller (DispatcherServlet) and it will then tries to find out appropriate Handler Mappings.
With the help of Handler Mappings, the DispatcherServlet will dispatch the request to appropriate Controller.
Also, The Controller tries to process the request and returns the Model and View object in form of ModelAndView instance to the Front Controller.
Moreover, The Front Controller then tries to resolve the View (which can be JSP, Freemarker, Velocity etc) by consulting the View Resolver object.
The selected view then rendered back to a client.
Features of Spring MVC Architecture 3.0
Spring 3.0 framework supports Java 5. It provides annotation based configuration support. Java 5 features such as generics, annotations, varargs etc can use in Spring.
Also, A new expression language Spring Expression Language SpEL introduced. The Spring Expression Language can use while defining the XML and Annotation based bean definition.
Spring 3.0 framework supports REST web services.
Data formatting can never be so easy. Spring MVC Architecture 3.0 supports annotation based formatting.
Moreover, We can now use the @DateFimeFormat(iso=ISO.DATE) and @NumberFormat(style=Style.CURRENCY) annotations to convert the date and currency formats.
Spring MVC Architecture 3.0 has started support for JPA 2.0.
Configuring Spring 3.0 MVC :
The entry point of Spring 3.0 MVC is the DispatcherServlet. DispatcherServlet is a normal servlet class which implements HttpServlet base class. Thus we need to configure it in web.xml.
In above code snippet, we have configured DispatcherServlet in web.xml. Note that we have mapped *.html url pattern with example DispatcherServlet.So Thus any url with the *.html pattern will call Spring MVC Front controller.
Also, Once the DispatcherServlet is initialized, it will look for a file name [servlet-name]servlet.xml in WEB-INF folder of web application. In above example, the framework will look for a file called example-servlet.xml.