XCMercy 2020-03-08
<!--1. SpringIOC容器配置加载 (listener)-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<!--classpath 表示加载【当前项目】类路径下的配置文件-->
<!--classpath* 表示加载【所有项目】类路径下的配置文件; 这里的所有项目就是指项目的所有jar包的类路径下。 -->
<param-value>classpath*:spring/applicationContext-*.xml</param-value>
</context-param>
<!--2. 编码过滤器 (filter)-->
<filter>
<filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--3. 配置SpringMVC前端控制器 (servlet)-->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<!--拦截路径: / 表示拦截所有路径,不包含jsp请求。要注意:一定要放行静态资源的访问-->
<!--拦截路径: *.do 表示拦截所有.do作为后缀的请求. 要注意:不支持restful请求-->
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>