了解springMVC的生命周期
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/\#spring-mvc-test-framework
配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<!--配置DispatherServlet-->
<servlet>
<servlet-name>killone-dispather</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--配置springmvc需要加载的配置文件-->
<!--mybatis->spring->springmvc-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>killone-dispather</servlet-name>
<!--默认匹配所有请求-->
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
配置spring-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvn="http://www.springframework.org/schema/mvc" xmlns:mvc="http://www.springframework.org/schema/mvc"
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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--配置springMVC-->
<!--1、开启springMVC注解模式-->
<!--这步做了什么:
1、自动注册DefaultAnnotationHandlerMapping,AnnotationMethodHandlerMapping
2、提供一系列功能:数据绑定,数字和日期的格式化,@DateTimeFormat,@NumberFormat,
xml,json的默认支持
-->
<mvn:annotation-driven/>
<!--2、静态资源默认servlet配置-->
<!--这步做了什么
1、加入对静态资源处理:js,png,jpg
2、允许使用"/"做映射
-->
<mvc:default-servlet-handler/>
<!--3、配置jsp,ViewResolver-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--4、扫描web相关的bean-->
<context:component-scan base-package="com.jimo.web"/>
</beans>