直接添加如下代碼就能夠解決問題了,不必作太多判斷java
String filename = java.net.URLEncoder.encode(file.getName(), "UTF-8"); response.setHeader("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + filename);
重點在filename*=utf-8'zh_cn',而後後面直接加文件名 .net
filename*=utf-8'zh_cn'