概述:
配置DispatcherServlet :
在web.xml中:
<!-- 业务层和持久层的spring配置文件,这些配置文件被父spring容器使用 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/conf/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 声明DispatcherServlet -->
<servlet>
<!-- 默认加载WEB-INF/baobaotao-servlet.xml 的spring配置文件,启动web层的spring容器 (注:默认是<name>-servlet.xml) -->
<servlet-name>baobaotao</servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- DispatcherServlet匹配的URL -->
<servlet-mapping>
<servlet-name>baobaotao</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>