Open the file directly when the browser downloads the file.

Source: Internet
Author: User

Sometimes, when downloading an object, it will become a browser to open it directly, rather than the download we want.

Perform the following configuration in CONF/Web. xml under tomcat5.x to solve the problem:

<Mime-mapping>

<Extension> CSV </extension>

<Mime-type> application/CSV </mime-type>

</Mime-mapping>

 

Reprinted below

Solve the problem of using IE to open the CSV file in resin or tomcat.

CSV file

<Mime-mapping>
<Extension> CSV </extension>
<Mime-type> application/Oct-stream </mime-type>
</Mime-mapping>

The solution is as follows:
Resin:
Open the conf/app-default.xml under the resin directory and add

 

 

<Web-app-default>
......
<Mime-mapping extension = ". XSL" mime-type = "text/XML"/>
<Mime-mapping extension = ". xwd" mime-type = "image/X-xwindowdump"/>
 
<Mime-mapping extension = ". CSV" mime-type = "application/Oct-stream"/>
 
<Mime-mapping extension = ". Zip" mime-type = "application/zip"/>
<Mime-mapping extension = ". Z" mime-type = "application/octet-stream"/>
 
<Resin: Import Path = "WEB-INF/Web. xml" Optional = "true"/>
<Resin: Import Path = "WEB-INF/resin-web.xml" Optional = "true"/>
</Web-app-default>

 

Tomcat:
Open CONF/Web. XML in the Tomcat directory and add
<Mime-mapping extension = ". CSV" mime-type = "application/Oct-stream"/>

 

 

 

========================================================== ========================================================== ==================

Solve the problem of using IE to open rarfile download in resin and tomcat
The reason is that the relevant mime and rarfile are not set in the resin and Tomcat server configurations.
The solution is as follows:
Resin:
Open the conf/app-default.xml under the resin directory and add
<Mime-mapping extension = ". rar" mime-type = "application/RAR"/>
Save, restart resin, and clear the temporary IE File (remember )!
Tomcat:
Open CONF/Web. XML in the Tomcat directory and add
<Mime-mapping>
<Extension> RAR </extension>
<Mime-type> application/RAR </mime-type>
</Mime-mapping>
Save, restart tomcat, and clear the temporary IE File (remember )!
Note: The same is true for downloading other types of files, such as TXT files. Change the corresponding RAR file to TXT.

 

========================================================== ========================================================== ==================

Web mime-Mapping
Used to specify the download format
<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>
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.