發現搜到的全部一樣的方案 new String(fileName.getBytes(), "ISO8859-1")
貼一個不一樣的解決方案
使用URLEncoder.encode
1
|
String attachName =
"這是中文名稱文件.txt"
//<a href="https://www.cnblogs.com/tomcatandjerry/p/11541871.html">https://www.cnblogs.com/tomcatandjerry/p/11541871.html</a>
|
1
2
3
|
response.setCharacterEncoding(
"utf-8"
);
response.setContentType(
"application/octet-stream"
);
response.setHeader(
"Content-Disposition"
,
"attachment;filename="
+ URLEncoder.encode(attachName,
"UTF-8"
));
|