|
@@ -13,7 +13,6 @@ import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
-import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
@@ -69,7 +68,10 @@ public class FileDisposeUtil {
|
|
|
//设置文件MIME类型
|
|
|
response.setContentType(getContentType(filename));
|
|
|
//设置Content-Disposition,名称强制为UTF-8
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(filename,"UTF-8"));
|
|
|
+ String fileEncode = System.getProperty("file.encoding");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes("UTF-8"),fileEncode));
|
|
|
+ // 设置强制下载不打开
|
|
|
+ response.setContentType("application/octet-stream;charset=utf-8");
|
|
|
//读取目标文件,通过response将目标文件写到客户端
|
|
|
//获取目标文件的绝对路径
|
|
|
//读取文件
|
|
@@ -199,5 +201,5 @@ public class FileDisposeUtil {
|
|
|
}
|
|
|
directory.mkdir();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|