Tomcat在返回静态资源时,会根据资源文件的扩展名产生对应的content-type头(也即MIME类型)添加到response header中. 在Tomcat的web.xml规定了扩展名及相应MIME的映射(占了web.xml 87%的篇幅),如下: <!-- ===================== Default MIME Type Mappings =================== --> <!-- When serving static resources, Tom…
一.servlet容器对url的匹配过程: 当一个请求发送到servlet容器的时候,容器先会将请求的url减去当前应用上下文的路径作为servlet的映射url,比如我访问的是http://localhost/test/aaa.html(我的应用上下文是test),容器会将http://localhost/tes去掉,将剩下的/aaa.html部分拿来做servlet的映射匹配,也就是拿这剩下的部分与web.xml中配置的servlet的url-pattern进行匹配.注意:这个映射匹配过程是…
Servlet和filter是J2EE开发中常用的技术,使用方便,配置简单.servlet和filter中的url-pattern有一些文章在里面的,总结了一些东西,以免遇到问题又要浪费时间. 一,servlet容器对url的匹配过程: 当 一个请求发送到servlet容器的时候,容器先会将请求的url减去当前应用上下文的路径作为servlet的映射url,比如我访问的是 http://localhost/test/aaa.html,我的应用上下文是test,容器会将http://localho…
web.xml中classpath:和classpath*:     IccBoY applicationContext.xml 配置文件的存放位置 web.xml中classpath:和classpath*:  有什么区别? classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. 存放位置:1:src下面需要在web.xml中定义如下:<context-param><param-name&…
<servlet-mapping> <servlet-name>downLoadFile</servlet-name> <url-pattern>*.loadfile</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>pageservlet</servlet-name> <url-pattern>/pages…
servlet和filter在javaEE开发中很常用,因此有必要知道web.xml文件映射的规则 1.  写法 ①完全匹配:以“/”开头,以字母(非“*”)结束    如:<url-pattern>/test/list.do</url-pattern> ②目录匹配:以“/”开头且以“/*”结尾    如:<url-pattern>/test/*</url-pattern>        <url-pattern>/*</url-patte…
classpath 和 classpath* 区别: classpath:只会到你指定的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. 举个简单的例子,在我的web.xml中是这么定义的:classpath*:META-INF/spring/application-context.xml 那么在META-INF/spring这个文件夹底下的所有application-context.xml都会被加载到上下文中,这些包括M…
文章转自:http://blog.csdn.net/sdyy321/article/details/5838791 有一般XML都必须有的版本.编码.DTD <web-app>下子元素<welcome-file-list>就是默认起始页,除了这个你还可以定义以下元素: <context-param>:web应用程序的servlet上下文初始化参数声明 <description>:提供关于web应用程序的描述性文本 <display-name>:指…
一.spring中如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个参数,spring会默认加载WEB-INF/applicationContext.xml文件(若没有,要新建一个). 例如: <context-param> <param-name>contextConfigLocation</param-name> <param-value&…
(转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个参数,Spring默认加载web-inf/applicationContext.xml文件. 例如: <context-param> <param-name>contextConfigLocation&l…