web.xml 2.32 KB
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" 
	     version="2.5" >
	
	<!-- 区分项目名称,防止默认重名 -->
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>maven.example.root</param-value>
	</context-param>
	
	 <!-- 设置Spring容器加载配置文件路径 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:spring/app*.xml</param-value>
	</context-param>

	<!-- Spring的log4j监听器 -->
<!--	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>-->


	<!-- spring监听器 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<!-- Spring 刷新Introspector防止内存泄露 -->
	<listener>
		<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
	</listener>


	<listener>
	<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>

	<!-- filter -->
	<filter>
		<filter-name>encodingFilter</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>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>


	<!-- Spring view分发器 -->
	<servlet>
		<servlet-name>dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>dispatcher</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>



	

	
	 <welcome-file-list>
       <welcome-file>/WEB-INF/views/index.jsp</welcome-file>
     </welcome-file-list> 

</web-app>