当前位置: 代码迷 >> Web前端 >> web.xml 中 mime-地图ping的使用
  详细解决方案

web.xml 中 mime-地图ping的使用

热度:494   发布时间:2012-08-31 12:55:03.0
web.xml 中 mime-mapping的使用
mime-mapping  如果Web应用程序包含一些不常用的文件,则需要确保分配某些MIME类型,mime-mapping元素正是为此而设计的。

        添加rar,iso等的mime-type映射,避免在浏览器里直接打开。

<mime-mapping>
<extension>mht</extension>
<mime-type>text/x-mht</mime-type>
</mime-mapping>
<mime-mapping>
        <extension>rar</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>iso</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>ape</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>rmvb</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>ico</extension>
        <mime-type>image/x-icon</mime-type>
    </mime-mapping>

   <mime-mapping>
   <extension>doc</extension>  
<mime-type>application/msword</mime-type>  
</mime-mapping>  
<mime-mapping>  
   <extension>xls</extension>  
   <mime-type>application/vnd.ms-excel</mime-type>  
</mime-mapping>  
<mime-mapping>  
   <extension>ppt</extension>  
   <mime-type>application/vnd.ms-powerpoint</mime-type>  
</mime-mapping>


对html静态页面设置编码
<!--  修改下面两行以支持静态超文本的自动编码 
  --> 
 <mime-mapping>
  <extension>htm</extension> 
  <mime-type>text/html;charset=gb2312</mime-type> 
  </mime-mapping>
 <mime-mapping>
  <extension>html</extension> 
  <mime-type>text/html;charset=gb2312</mime-type> 
  </mime-mapping>