1. A subordinate descriptors (web.xml) Configuration
1.1url-pattern configuration / instead of / *
tomcat servlet processing various requests have their own built-in, if the / * end .jsp will intercept the request and forwards it to its own built-in processor servlet, so that request fails
1.2 Customizing the loading time DispatcherServlet
May be <servlet>
added in <load-on-startup>1</load-on-startup>
so disposed DispatcherServlet loaded server startup, when loading occurs if a write request arrives at a first HTTP
1.3 Custom SpringMvc profile path
In <servlet>
writing<init-param> <param-name>contextConfigLocation</param-name><parm-value>url</parm-value></init-param>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>project2</display-name>
<servlet>
<servlet-name>springMvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springMvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
2SpringMvc profile
2.1 wildcard configuration is very comprehensive, but can not find annotation solution
Join these two configuration statements in the beans mean MVC uses this file to resolve http://www.springframework.org/schema/mvc/spring-mvc.xsd
xmlns:mvc=“http://www.springframework.org/schema/mvc”
xsi:http://www.springframework.org/schema/mvc/spring-mvc.xsd ">
2.2 springMvc encoding format configuration file declaration response to UTF-8
Meaning utf-8 assigned to the first parameter getMessageConverters (element, source, parserContext) is called during the execution HttpMessageConverter write method, HttpMessageConverter is a method for data type matching at front and rear ends interaction information, there five methods: canRead, read, write, canWrite, getSupportedMediaTypes
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg index="0" value="utf-8"></constructor-arg>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd ">
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg index="0" value="utf-8"></constructor-arg>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<context:component-scan base-package="com.project2"></context:component-scan>
</beans>