<param-value>classpath:application-context.xml</param-value>
</context-param>
<!--spring
监听器
-->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
在
web.xml
中配置
springmvc
的前端控制器
(
中央处理器
),
配置如下:
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServl
et</servlet-class>
<init-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<!--
加载
web.xml
配置文件的时候立即实例化
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<!--/*:
拦
截
所
有
的
请
求
跳
转
视
图
都
会
拦
截
比
如
/WEB-INF/jsp/item.jsp
/:
拦
截
所
有
的
请
求
跳
转
视
图
不
拦
截
不
过
会
拦
截
.css .js .doc ...
*.do:
拦截
.do
后缀的请求
-->
<url-pattern>*.do</url-pattern>
</servlet-mapping>
在
web.xml
中配置请求时中文乱码过滤器
,
配置如下:
<filter>
<filter-name>encoding</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filte
r-class>
<init-param>
<param-name>
encoding
</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>