web.xml配置中的<mime-mapping>

<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zip</extension>
<mime-type>application/zip</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rar</extension>
<mime-type>application/rar</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>application/txt</mime-type>
</mime-mapping>
<mime-mapping>
<extension>chm</extension>
<mime-type>application/mshelp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>mp3</extension>
<mime-type>audio/x-mpeg</mime-type>
</mime-mapping> 


常见的MIME类型

超文本标记语言文本 .htm,.html text/html
普通文本 .txt text/plain
RTF文本 .rtf application/rtf
GIF图形 .gif image/gif
JPEG图形 .ipeg,.jpg image/jpeg
au声音文件 .au audio/basic
MIDI音乐文件 mid,.midi audio/midi,audio/x-midi
RealAudio音乐文件 .ra, .ram audio/x-pn-realaudio
MPEG文件 .mpg,.mpeg video/mpeg
AVI文件 .avi video/x-msvideo
GZIP文件 .gz application/x-gzip
TAR文件 .tar application/x-tar


1.指定了自己的javaEncoding

<servlet>
       <servlet-name>jsp</servlet-name>
       <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
       <init-param>
           <param-name>fork</param-name>
           <param-value>false</param-value>
       </init-param>
               <init-param>
           <param-name>javaEncoding</param-name>
           <param-value>GB18030</param-value>
       </init-param>
       <init-param>
           <param-name>xpoweredBy</param-name>
           <param-value>true</param-value>
       </init-param>
       <load-on-startup>3</load-on-startup>
   </servlet>

 2.添加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>

3.对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>
  </web-app>



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值