Forráskód Böngészése

修改linux路径问题

wangyanygang 4 éve
szülő
commit
42f4742470

+ 6 - 5
user_center/src/main/java/com/huaxu/common/ToolUtil.java

@@ -242,14 +242,15 @@ public class ToolUtil {
         if (!StringUtils.startsWithAny(p, "/") && StringUtils.startsWithAny(path, "\\", "/")) {
             p += "/";
         }
-//        if (!StringUtils.endsWithAny(p, "/") && StringUtils.endsWithAny(path, "\\", "/")) {
-//            p = p;//+ "/";
-//        }
+        if (!StringUtils.endsWithAny(p, "/") && StringUtils.endsWithAny(path, "\\", "/")) {
+            p = p + "/";
+        }
         if (path != null && path.startsWith("/")) {
             p = "/" + p; // linux下路径
         }
-
-
+        if (StringUtils.endsWithAny(p, "/")) {
+            p = p.substring(0, p.length() - 1);
+        }
         return p;
     }