Selaa lähdekoodia

修改中文路径乱码问题

DESKTOP-2K9OVK9\siwei 4 kuukautta sitten
vanhempi
commit
e24da53cd6

+ 3 - 2
onemap-modules/onemap-file/src/main/java/com/onemap/file/controller/SysFileController.java

@@ -26,6 +26,7 @@ import org.springframework.web.servlet.HandlerMapping;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -297,7 +298,7 @@ public class SysFileController {
             String bestMatchingPattern = request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE).toString();
             // 提取与模式相匹配的部分(不包括通配符)
             String extractedPath = antPathMatcher.extractPathWithinPattern(bestMatchingPattern, path);
-            String uploadFile = spaceFileRecordService.uploadAbsolutePath(extractedPath);
+            String uploadFile = spaceFileRecordService.uploadAbsolutePath(URLDecoder.decode(extractedPath, "UTF-8"));
             // 构建文件的完整路径
             Path filePath = Paths.get(uploadFile);
             Resource resource = new FileSystemResource(filePath.toFile());
@@ -341,7 +342,7 @@ public class SysFileController {
             String bestMatchingPattern = request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE).toString();
             // 提取与模式相匹配的部分(不包括通配符)
             String extractedPath = antPathMatcher.extractPathWithinPattern(bestMatchingPattern, path);
-            String uploadFile = spaceFileRecordService.uploadAbsolutePath(extractedPath);
+            String uploadFile = spaceFileRecordService.uploadAbsolutePath(URLDecoder.decode(extractedPath, "UTF-8"));
             // 构建文件的完整路径
             Path filePath = Paths.get(uploadFile);
             Resource resource = new FileSystemResource(filePath.toFile());

+ 1 - 1
onemap-modules/onemap-file/src/main/java/com/onemap/file/service/impl/SpaceFileRecordServiceImpl.java

@@ -379,7 +379,7 @@ public class SpaceFileRecordServiceImpl implements ISpaceFileRecordService {
 
     @Override
     public String uploadAbsolutePath(String file) {
-        String unzipPath = uploadFilePath + file;
+        String unzipPath = uploadFilePath + "/" + file;
         return unzipPath;
     }
 }