Configure the download file type in the web. xml file

Source: Internet
Author: User

 



Tomcat downloads .rar files as text, so that IE opens rarfiles as garbled characters. In this case, you do not have to consider it a browser problem, most browsers should not expose binary files as text. Generally, the server opens binary files for any browser. solution:

Open CONF/Web. xml and add the following code.

<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>

Restart tomcat, clear ie cache, and download RAR files normally.

Common MIME types

Hypertext markup language text .htm,.html text/html
Common text. TXT text/plain
RTF text. rtf
Application/RTF
GIF image. GIF image/GIF
JPEG image .ipeg,.jpg image/JPEG

AU audio file. Au audio/basic
MIDI music files mid,. MIDI audio/Midi, audio/X-Midi

RealAudio music file. Ra,. Ram audio/X-PN-RealAudio
MPEG file. mpg,. MPEG
Video/MPEG
AVI file. AVI Video/X-msvideo
Gzip file. GZ application/X-Gzip

Tar file. Tar application/X-Tar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.