<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 如果applicationContext.xml不在web-info下则要配置 -->
<context-param>
<param-name>contextConfigLocation</param-name><!--contextConfigLocation名不能改 -->
<param-value>classpath:config/applicationContext.xml</param-value>
</context-param>
<!-- 配置spring mvc -->
<servlet>
<servlet-name>qq</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 如果qq-servlet.xml放在web-info文件夹下则不用配置,contextConfigLocation名不能改 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/springmvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>qq</servlet-name>
<url-pattern>*.do</url-pattern><!-- 是spring mvc开发习惯要.do结尾,struts要用.action -->
</servlet-mapping>
<!-- spring mvc处理乱码 -->
<filter>
<filter-name>bm</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<!-- 设置编码参数 -->
<init-param>
<param-name>encoding</param-name><!--encoding不能变 -->
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>bm</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
网友评论