web应用配置文件详解(web.xml)
转载链接地址:http://blog.csdn.net/guihaijinfen/article/details/8363839
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <context-param> <param-name>contextConfigLocation</param-name> <!-- 如果有多个xml参数需要加载,可以使用通配符(*)或者用逗号(",")隔开 --> <param-value>classpath:application-context.xml</param-value> </context-param> <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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <!-- 在web.xml中增加对springMVC框架的支持,其实就是增加SpringMVC框架核心过滤器的servlet的配置 --> <servlet-name>spring-mvc</servlet-name> <!-- SpringMVC的核心控制器(前端控制器),控制分发配置 --> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <!-- 指定配置文件的全名,如果不指定,则为这里的servlet-name的属性SpringMVC+"-servlet.xml" --> <param-name>contextConfigLocation</param-name> <!-- 配置文件的地址 如果不配置contextConfigLocation, 默认查找的配置文件名称classpath下的:servlet名称+"-serlvet.xml"即:springmvc-serlvet.xml --> <param-value>classpath:spring-mvc.xml</param-value> <!-- 启动服务器时创建此serlvet核心对象 --> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring-mvc</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>