File stream output file name does not display in Chinese
response returns the file stream and use ("Content-disposition", "attachment; filename="+fileName); the Chinese name of the result is displayed with "—" and slide down.
No solution using the following method
(“UTF-8”); (“text/html;charset=UTF-8”); (new (“zh”,“CN”));
The reason is that these operations are encoding settings for the returned content, and my file name is set to the header;
Solution
Convert file name to ASCII code ~
as follows:
// Ten thousand lines of code are not displayedOutputStream output = null; try { (); ("application/msexcel;charset=UTF-8"); // ("UTF-8"); fileName = (fileName,"UTF-8"); output = (); ("Content-disposition", "attachment; filename="+fileName); (output); if(output != null) (); } catch (IOException e) { // TODO (); }
Chinese file name garbled when downloading response
FileInfo info = new FileInfo(strFilePath); long fileSize = ; (); = true; = "application/x-zip-compressed"; ("Accept-Language", "zh-cn"); ("Content-Disposition", "attachment;filename=" + ()); //If Content-Length is not specified, the download progress will not be displayed if it is Flush.("Content-Length", ()); (strFilePath, 0, fileSize); (); (); ();
The above is personal experience. I hope you can give you a reference and I hope you can support me more.