mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
作业导出bug
This commit is contained in:
@@ -399,11 +399,20 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("导出异常");
|
||||
}
|
||||
|
||||
long totalCompressedSize = 0;
|
||||
String encodedFilename = URLEncoder.encode("作业.zip")
|
||||
.replace("+", "%20") // 空格替换为"%20"
|
||||
.replace("%2F", "/"); // 解决斜杠问题
|
||||
StringBuilder contentDispositionValue = new StringBuilder();
|
||||
contentDispositionValue.append("attachment; filename=\"")
|
||||
.append(encodedFilename)
|
||||
.append("\"")
|
||||
.append("; filename*=utf-8''")
|
||||
.append(encodedFilename);
|
||||
|
||||
// 设置响应类型和Content-Disposition头
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", contentDispositionValue.toString());
|
||||
long totalCompressedSize = 0;
|
||||
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
File fileToZip = new File(e.getValue());
|
||||
@@ -429,16 +438,6 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
|
||||
zos.closeEntry();
|
||||
}
|
||||
StringBuilder contentDispositionValue = new StringBuilder();
|
||||
contentDispositionValue.append("attachment; filename=")
|
||||
.append(encodedFilename)
|
||||
.append(";")
|
||||
.append("filename*=")
|
||||
.append("utf-8''")
|
||||
.append(encodedFilename);
|
||||
// 设置响应类型和Content-Disposition头
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", contentDispositionValue.toString());
|
||||
}
|
||||
}
|
||||
@GetMapping("/detail-study")
|
||||
|
||||
Reference in New Issue
Block a user