springMVC之web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>CalendarManager</display-name> <!--负责启动spring容器的监听器 begin--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!--负责启动spring容器的监听器 begin--> <!--从类路径下加载spring的配置文件,classpath关键字特指类路径下加载 begin--> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:applicationcontext.xml </param-value> </context-param> <!--从类路径下加载spring的配置文件,classpath关键字特指类路径下加载 begin--> <!--声明springMVC 的 DispatcherServlet begin--> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:servlet-*.xml</param-value> </init-param> <!--必须是个整数,表示servlet应该被载入的顺序; 当值为0或者大于0时,表示容器在应用启动时就加载并初始化这个servlet; 当值小于0或者没有指定时,则表示容器在该servlet被选择时才会去加载; 正数的值越小,该servlet的优先级越高,应用启动时就越先加载; 当值相同时,容器就会自己选择顺序来加载 --> <load-on-startup>1</load-on-startup> </servlet> <!--声明springMVC 的 DispatcherServlet end--> <!--拦截器配置 begin--> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!--拦截器配置 end--> <!--编码过滤器 begin--> <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中的url-pattern为过滤的url类型--> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>*</url-pattern> </filter-mapping> <!--编码过滤器 end--> <!--默认欢迎界面 begin--> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <!--默认欢迎界面 end--> </web-app>