Welcome 微信登录

首页 / 网页编程 / ASP.NET / web.xml学习(7)_mime-mapping、welcome-file-list、error-page

web.xml学习(7)_mime-mapping、welcome-file-list、error-page2015-04-0110.mime-mapping:mime-mapping包含两个子元素extension和mime-type.定义某一个扩展名和某一MIME Type做对映.

MIME(Multipurpose Internet Mail Extensions)多用途互联网邮件扩展类型就是设定某种扩展名的文件用一种应用程序来打开的方式类型,

当该扩展名文件被访问的时候,浏览器会自动使用指定应用程序来打开。多用于指定一些客户端自定义的文件名,以及一些媒体文件打开方式

浏览器接收到文件后,会进入插件系统进行查找,查找出哪种插件可以识别读取接收到的文件。

如果浏览器不清楚调用哪种插件系统,它可能会告诉用户缺少某插件,或者直接选择某现有插件来试图读取接收到的文件,后者可能会导致系统的崩溃。

传输的信息中缺少MIME标识可能导致的情况很难估计,因为某些计算机系统可能不会出现什么故障,但某些计算机可能就会因此而崩溃。

<!-- mime-mapping包含两个子元素extension和mime-type.定义某一个扩展名和某一MIME Type做对映.--> <mime-mapping> <!-- 扩展名称--> <extension>htm</extension> <!-- MIME格式--> <mime-type>text/html</mime-type> </mime-mapping>
11.welcom-file-list :指示服务器在收到引用一个目录名而不是文件名的URL时,使用哪个文件。

<welcome-file-list>

welcome-file-list包含一个子元素welcome-file.用来定义首页列单.

<welcome-file>用来指定首页文件名称</welcome-flie>

welcome-file用来指定首页文件名称.我们可以用<welcome-file>指定几个首页,而服务器会依照设定的顺序来找首页.

范例:

<welcome-file-list><welcome-file>index.jsp</welcome-file><welcome-file>index.htm</welcome-file></welcome-file-list>
12.error-page:使得在返回特定HTTP状态代码时,或者特定类型的异常被抛出时,能够制定将要显示的页面。

error-page元素包含三个子元素error-code,exception-type和location.将错误代码(Error Code)或异常(Exception)的种类对应

到web站台资源路径.

<error-code>错误代码</error-code>

HTTP Error code,例如: 404

<exception-type>Exception</exception-type>

一个完整名称的Java异常类型

<location>/路径</location>

在web站台内的相关资源路径

</error-page>

范例:

<error-page> <error-code>404</error-code> <location>/error404.jsp</location></error-page><error-page> <exception-type>java.lang.Exception</exception-type> <location>/except.jsp</location></error-page>