Home  >  Article  >  What framework is springmvc?

What framework is springmvc?

anonymity
anonymityOriginal
2019-05-06 13:54:484619browse

The JavaEE architecture consists of four layers, from top to bottom: application layer, Web layer, business layer, and persistence layer. Struts and SpringMVC are the frameworks of the Web layer, Spring is the framework of the business layer, and Hibernate and MyBatis are the frameworks of the persistence layer.

Why use SpringMVC?

The problem with many applications is that there is a tight coupling between the objects that process business data and the views that display the business data. Typically, commands to update business objects are initiated from the view itself, making the view Any business object changes are highly sensitive. Furthermore, there is no flexibility when multiple views depend on the same business object.

SpringMVC is a lightweight Web framework based on Java that implements the Web MVC design pattern and is request-driven. It uses the idea of ​​​​the MVC architectural pattern to decouple the responsibilities of the Web layer. Request-driven means using the request-response model. The purpose of the framework is to help us simplify development. SpringMVC also aims to simplify our daily web development.

What framework is springmvc?

MVC design pattern

The task of the MVC design pattern is to decouple the module containing business data from the view that displays the module. How did this happen? Introducing a redirection layer between model and view can solve the problem. This redirection layer is the controller that will receive the request, perform the action of updating the model, and then notify the view about the model change.

Specific process:

(1) First, the user sends a request——>DispatcherServlet. After the front-end controller receives the request, it does not process it, but delegates it to Other parsers perform processing as a unified access point for global process control;

(2) DispatcherServlet——>HandlerMapping, the processor mapper will map the request to a HandlerExecutionChain object (containing a Handler Processor object, multiple HandlerInterceptor interceptor) objects;

(3) DispatcherServlet——>HandlerAdapter, the processor adapter will package the processor as an adapter to support multiple types of processors, that is The application of the adapter design pattern makes it easy to support many types of processors;

(4) HandlerAdapter——> Call the corresponding function processing method of the processor and return a ModelAndView object (including model data, logical view name);

(5) ModelAndView object (the Model part is the model data returned by the business object, the View part is the logical view name) -> ViewResolver, the view resolver will parse the logical view name into a specific View;

(6) View -> Rendering, View will render according to the incoming Model model data. The Model here is actually a Map data structure;

(7) Return control to DispatcherServlet, and DispatcherServlet returns a response to the user. This is the end of the process.

The above is the detailed content of What framework is springmvc?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn