How to use Firefox to download garbled characters of Chinese file names

Source: Internet
Author: User

For Java-written downloads, it is normal to use IE by default and 360 browsers for downloads. The text in the file name is garbled during the download using Firefox, and the solution is recorded here:

First, make a judgment on the page to determine the browser, and then pass a parameter to the servlet for different encoding methods:
Firefox:
Response. addheader ("content-disposition", "attachment; filename =" + new string (filename. getbytes ("gb2312"), "ISO-8859-1 "));
IE and others:
Response. addheader ("content-disposition", "attachment; filename =" + urlencoder. encode (filename, "UTF-8 "));


For details, refer to the following link:

Http://bbs.csdn.net/topics/370099592


By the way, how does Java determine the browser type:

Request. getheader ("User-Agent") contains information such as the browser operating system.

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.