Article From:

Answer 0:

Spring Web MVC The general process of processing Http requests:
Once the Http request arrives, DispatcherSevlet will be responsible for distributing the request. The Dispatcher Servlet can be thought of as a front-end controller provided by Spring, through which all requests are distributed uniformly.
Before Dispatcher Servlet distributes the request to Spring Controller, you need to locate the specific Controller with the help of the Handler Mapping provided by Spring. HandlerMappIng is such an object that it can complete the mapping between customer request and Controller. In Struts, this mapping is done through the struts-config.xml file. Among them, Spring provides Controller interface.A number of implementations, such as the default BeanNameUrlHandlerMapping used by Spring. And, SimpleUrlHandlerMapping, CommonsPathMapHandlerMapping.
Spring ControllerThe request from DispatcherServlet will be processed. Spring’s Controller is similar to struts’s Action, and can accept HttpServletRequest and HttpServletRespon.Se. Spring provides several implementation classes for the Controller interface, located in the org. springframework. web. servlet. MVC package. Since Controller needs to process the above requests for concurrent users, it is therefore necessary to implement the above requests.When Controller interfaces are present, thread safety must be ensured and reusable. Controller will handle customer requests, which is consistent with the role Struts Action plays.
Once the Controller has processed the customer request, the ModelAndView object is returned to the Dispatcher Servlet front-end controller. ModelAndView includes models (Model) and views (View). From the macro angleFor degree considerations, the Dispatcher Servlet is the controller for the entire Web application; from a microscopic point of view, the Controller is the controller for a single Http request processing, and the Model AndView is the model returned during the Http request processing.View. The view returned by the front-end controller can be the logical name of the view, or the object of the View interface. View objects can render client response results. Among them, the model in ModelAndView can be used for rendering View. With Map object, it can store modules.Type.
If the view returned by ModelAndView is just a logical name, you need to find the View object in a Web application with the help of Spring’s View Resoler to render the response result to the client.
DispatcherServletThe result rendered by the View object is returned to a customer.

Answer 1:

springWe will take this VIEWNAME (path) to find the resources, then render it and return it to the front end.

Similar Posts:

Leave a Reply

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