Architecture of the Spring WEB MVC
Thursday, December 24th, 2015 (0 Comment)
1. Overview spring web mvc
- Spring web MVC framework is a full-featured installation MVC to build Web applications. The MVC framework is configured via interfaces and contains many new technologies including JSP, Velocity, Tiles, and generation of PDF and Excel files
Models in spring web mvc include the java class
- Show data and allow access to data to get and set in JavaBean, this layer often the first full simulation objects from the real world.
- Receive requests from view.
- Enforcement of these requirements (calculations, database connection …)
- Returns the value calculated at the request of Controller
- In spring web mvc Control between view and model. A JSP page will be corresponding with a java class to handle it and vice versa, the result will return a jsp page. It’s moderator role between View and Model
- As such, we can separate the java code from html code. Therefore, it has solved the problems raised in the model 1. The interface design and java programmers can carry relatively independent nature.
- The debug or maintenance will be easier, changing the theme of the site is also easier …
5. Spring Web MVC
- Spring Framework supports many frameworks and libraries. It allows developers to mix and match multiple framework when developing and deploying applications. The Spring Web MVC has advantages from the Spring framework and provides a best time and effective framework for the development of web applications.
- The Spring Web MVC is a web development framework based on design patterns MVC (Model View Controller). Features of Spring Web MVC framework is pluggable technology and Injection View service in control.
6. Processing mechanism Request-Respone
- In the same other java-base framework MVC, Spring Web MVC requests must also through a front controller servlet. A front controller servlet sole is representative responsible for the other components required by an application to perform the actual processing. In the case of Spring Web MVC, DispatcherServlet is the controller forward.
- A Request submitted by DispatcherServlet to control (to be selected through a mapping process). When controlling completed, request is then sent to the view (which is selected through ViewResolver) to make the output.
7. Description for the data flow diagram
- Request sent to DispatcherServlet.
- DispatcherServlet requests to the Handler Mapping (A map configuration URL) to determine how the controller will handle this request.
- DispatcherServlet requests to the Controller after known Controller that will handle the request. If such a request need to access the database, the Controller shall authorize another to business logic, or more than one service Objects (MODEL) to get information and send data back to the moment Controller. Controller packaged data models and name of a shared view of the object uploaded ModelAndView.
- ModelAndView package is sent back to DispatcherServlet.
- Dispatcher Servlet send ModelAndView for ViewResolver package to find out the site (JSP) will be loaded. DispatcherServlet loads the page along with its data.
8. Configuring DispatcherServlet
- DispatcherServlet acts as the heart of Spring web MVC. A servlet can function like Spring MVC’s front controller. Like any servlet, DispatcherServlet should be configured in the web.xml file
- By default, when DispatcherServlet is loaded, it will turn off the Spring application context XML file and named based on the name of the servlet.
Tags: spring, spring mvc, spring web mvc