|
@@ -35,6 +35,7 @@ import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.BufferedOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
@@ -156,9 +157,22 @@ public class DataMigrationController {
|
|
|
//设置响应的内容类型
|
|
|
response.setContentType("text/plain");
|
|
|
//设置文件的名称和格式
|
|
|
+
|
|
|
+ String encode = StandardCharsets.UTF_8.name();
|
|
|
+ response.setCharacterEncoding(encode);
|
|
|
+ // 防止中文乱码
|
|
|
+ String fileName = context.getProjectId()+"_迁移sql";
|
|
|
+
|
|
|
+ try {
|
|
|
+ fileName = URLEncoder.encode(fileName, encode);
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
response.addHeader("Content-Disposition","attachment;filename="
|
|
|
- + genAttachmentFileName(context.getProjectId()+"_迁移sql", "JSON_FOR_UCC_")//设置名称格式,没有这个中文名称无法显示
|
|
|
+ + fileName
|
|
|
+ ".sql");
|
|
|
+
|
|
|
BufferedOutputStream buff = null;
|
|
|
ServletOutputStream outStr = null;
|
|
|
try {
|
|
@@ -179,15 +193,6 @@ public class DataMigrationController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String genAttachmentFileName(String cnName, String defaultName) {
|
|
|
- try {
|
|
|
- cnName = new String(cnName.getBytes("gb2312"), "ISO8859-1");
|
|
|
- } catch (Exception e) {
|
|
|
- cnName = defaultName;
|
|
|
- }
|
|
|
- return cnName;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取迁移数据日志
|
|
|
*
|