File download Chinese garbled, because the HTTP request URL and header requirements only through the ASCII code, for other characters do not, need to transcode. and different browsers are handled differently right.
Workaround One:
/** * Garbled solution * @throws unsupportedencodingexception * */private static string toutf8bytesstring (String fileName, Httpse Rvletrequest req) throws unsupportedencodingexception {//return new String (Filename.getbytes ("GBK"), "iso8859-1"); if ( Req.getheader ("User-agent"). toUpperCase (). IndexOf ("MSIE") > 0) {return Urlencoder.encode (fileName, "UTF-8");} Else{return New String (Filename.getbytes ("UTF-8"), "iso8859-1");}}
Workaround Two:
This method in the Windows Chinese system new version of Firefox, ie, chrome download will not be garbled, do not know the other system default character set non-GBK will be problematic
New String (Filename.getbytes ("GBK"), "iso8859-1")
Resources:
Http://www.ruanyifeng.com/blog/2010/02/url_encoding.html
Java Web upload Download garbled problem solving method