The overall design of Spring MVC

Source: Internet
Author: User

To use sping MVC, you only need to configure a Dispatcherservlet in Web. xml:

1 <servlet>2     <Servlet-name>Dispatcherservlet</Servlet-name>3     <Servlet-class>4 Org.springframework.web.servlet.DispatcherServlet5     </Servlet-class>6 </servlet>7 <servlet-mapping>8     <Servlet-name>Dispatcherservlet</Servlet-name>9     <Url-pattern>/*</Url-pattern>Ten </servlet-mapping>

Define a Dispatcherservlet-servlet.xml configuration file again:

1 <Beans>2     <!--Define Mapping -3     <BeanID= "UrlMapping"class= "Org.springframework.web.servlet.handler.simpleurlhandler-mapping">4       < Propertyname= "Mappings">5         <Props>6           <propKey= "demo.html">Demo</prop>7         </Props>8       </ Property>9       < Propertyname= "Interceptors">Ten         <List> One           <refBean= "Interceptor" /> A         </List> -      </ Property> -     </Bean> the     <BeanID= "Interceptor"class= "Org.springframework.web.servlet.theme.ThemeChangeInterceptor"/> -     <!--Define View - -     <BeanID= "Viewresolver"class= "Org.springframework.web.servlet.view.internalresource-viewresolver"> -       < Propertyname= "Viewclass"> +         <value>Org.springframework.web.servlet.view.internalresource-view</value> -       </ Property> +     </Bean> A     <!--Define Control - at     <BeanID= "Demo"class= "Com.yb.mvc.demo"> -       < Propertyname= "ViewPage"> -         <value>/demo.html</Valus> -       </ Property> -     </Bean> - </Beans>

Such a simple spring MVC-based application is created.

The use of spring MVC is simple, as shown in the code above, as long as we extend a path mapping relationship, define a view parser, and in defining a process plan for a business logic, Spring MVC can help us do all of the MVC functions.

Dispatcherservlet class-related structure diagram:

  

The Dispatcherservlet class inherits the HttpServlet and Dispatcherservlet performs the initialization of Spring MVC when the Servlet's Init method is called. Dispatcherservlet initializes what can be known in its Initstrategies method:

The overall design of Spring MVC

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.