1. Configure Web. XML to start SPRINGMVC
<!--start Spring mvc-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--If you do not configure the following: Spring MVC configuration files are placed by default in web-inf/[springmvc-name]-servlet.xml-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--troubleshoot post submissions garbled--
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
2, the XML----------------is obsolete "not recommended use"
1), configure handlermapping, request map to Controller
<bean class= "Org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" ></bean>
2), configuration Handleradapter, support multi-type processor
<bean class= "Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" ></bean>
See more:/org/springframework/web/servlet/dispatcherservlet.properties file pieces
4, the implementation of the Controller
Implements the Controller class and its subclasses. Implement the appropriate method.
5. Contextual relationship (Spring-spring MVC)
Spring MVC inherits the spring context.
View: Dispacherservlet The Initservletbean method of the parent class Frameworkservlet.
6, Annotation Way
1), configure handlermapping, request map to Controller
<bean class= "Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" ></bean >
2), configuration Handleradapter, support multi-type processor
<bean class= "Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" ></bean>
See more:/org/springframework/web/servlet/dispatcherservlet.properties file pieces
7. Define the View parser
<!--View Resolver--
<bean class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "Viewclass" value= "Org.springframework.web.servlet.view.JstlView" ></property>
<property name= "prefix" value= "/view/" ></property>
<property name= "suffix" value= ". JSP" ></property>
</bean>
Spring MVC General overview