阅读背景:

springMvc环境搭建

来源:互联网 

web.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>web-ljgc</display-name>
  <!-- springmvc 框架配置 -->
	  <servlet>
	  	<servlet-name>action</servlet-name>
	  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	  	<init-param>
<!--contextConfigLocation:指定springmvc配置的加载地位,如果不指定则默许加
载WEB-INF/[DispatcherServlet 的Servlet 名字]-servlet.xml。-->
	  		<param-name>contextConfigLocation</param-name>
	  		<param-value>classpath:spring-mvc.xml</param-value>
	  	</init-param>
	  </servlet>
	  <!-- 配置一个映照的路径 -->
	  <servlet-mapping>
	  		<servlet-name>action</servlet-name>
	  		<url-pattern>/</url-pattern> 	
	  </servlet-mapping>
	<!-- 配置一个编码过滤器  spring-mvc 自带的一个编码转换-->
	
	<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>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app><?xml version="1.0" encoding="UTF-8"?>




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: