SPRINGMVC Series One configuration introduction (including the official website Doc)

Source: Internet
Author: User

1.SPRINGMVC website Reference Address:

  Https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html

2. Introduction of SPRINGMVC

Spring Web MVC is the original web framework built on the servlet API, so it is included in the spring framework from the beginning.

3.Dispatcherservlet

 SPRINGMVC, like most web frameworks, acts as a core front-end controller. The Dispatherservlet inheritance servlet provides the distribution client to send the request to the appropriate handler. This model smoothly supports different workflows. (page request, file upload, etc.); Dispatcherservlet is a server-side application that, if you want to implement SPRINGMVC as a control layer, you need to configure this sevlet in Web. XML so that the servlet will use spring Configuration items in the configuration file. For example, get the request requests from the front end, bind the carried parameters to the controller

Configuration of the 4.web.xml

  In fact, this configuration is very similar to the configuration of Struts2, is the core controller configuration, the following is the SPRINGMVC-based configuration

<Web-app>
<!--configuring monitoring, listening profile---<Listener> <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class> </Listener>
<!--introduce the SPRINGMVC configuration file, which is configured in multiple ways-<Context-param> <Param-name>Contextconfiglocation</Param-name>
      
<!--Way 1--><Param-value>/web-inf/app-context.xml</Param-value>
         <!--Way 2->
  <!--     <param-value>classpath:*-context.xml</param-value>--   
    </Context-param>
<!--load the front-end controller in<servlet> <Servlet-name>App</Servlet-name> <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <Init-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>
Classpath:spring-mvc.xml
</param-value>
        </Init-param>        <Load-on-startup>1</Load-on-startup>    </servlet>
<!--Configure filtering requests--<servlet-mapping> <Servlet-name>App</Servlet-name> <Url-pattern>*.do</Url-pattern> </servlet-mapping> </web-app>

5. Special Bean

Dispatcherservlet just as a front-end controller, the specific business processing will be given to the specific bean for processing. You can customize or extend a particular bean to handle the corresponding business scenario.

A. Handlermapping: Maps the request to the corresponding processor according to the request sent by the client

B. Handleradapter: The adapter handles the request according to the client's request, dividing the adapter according to specific details

C. Viewresolver: View parser, encapsulates the data returned by the controller into the view and looks for the specified view for presentation

D. Multipartresolver: Rich Text parser: such as returning pdf/img/excel, etc.

E. Themeresolver: Return to different topics

The process of 6.dispatcher execution

First dispatcher accepts the user's request, the front-end controller accepts the request not to do its own processing, but delegates to the other parser processing, dispatcher as a unified site for the global Process Control.

Handlermapping mapping requests received from dispatcher to Handlerexecutionchain objects (containing a handler processor object, multiple interceptors)

The Handleradapter will wrap the processor into an adapter to support multiple types of processors. It then invokes the true processor based on the result of the adaptation and returns a Modelandview object containing the model data. Logical view name)

Viewresolver to parse the logical view name into a specific view

View renders the page based on the model data passed in

Returns control to dispatcher and responds to the user by his return

  

SPRINGMVC Series One configuration introduction (including the official website Doc)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.