Java download file, the file name cannot be displayed in Chinese

Before, we generally wrote like this:

response.setHeader("Content-Disposition", "attachment; filename=" + fileName);

The reason why the downloaded file cannot display the Chinese file name is because it needs to convert UTF-8 encoding to ISO-8858-1 encoding.

 response.setHeader("Content-Disposition", "attachment; filename=" 
                    + new String(fileName.getBytes("utf-8"),"ISO-8859-1"));

 

Published 34 original articles · received 1 · views 1946

Guess you like

Origin blog.csdn.net/qq_38974638/article/details/104803406