|
|
@@ -1,6 +1,8 @@
|
|
|
package com.uas.platform.b2b.core.util;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
|
|
|
/**
|
|
|
* 路径
|
|
|
@@ -50,13 +52,18 @@ public class PathUtils {
|
|
|
}
|
|
|
|
|
|
private static void setClassPath() {
|
|
|
- Class<PathUtils> cls = PathUtils.class;
|
|
|
- int len = cls.getName().split("\\.").length - 1;
|
|
|
- File file = new File(cls.getResource("").getPath());
|
|
|
- for (int i = 0; i < len; i++) {
|
|
|
- file = file.getParentFile();
|
|
|
+ Class<?> objClass = ContextUtils.getApplicationContext().getClass();
|
|
|
+ String strRealPath = objClass.getClassLoader().getResource("").getFile();
|
|
|
+ try {
|
|
|
+ strRealPath = URLDecoder.decode(strRealPath, "UTF-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ File objFile = new File(strRealPath);
|
|
|
+ classPath = objFile.getParent() + File.separator;
|
|
|
+ if (classPath.contains("/")) {
|
|
|
+ classPath = "/" + classPath;
|
|
|
}
|
|
|
- classPath = file.getAbsolutePath().replaceAll("%20", " ");
|
|
|
}
|
|
|
|
|
|
private static void setAppPath() {
|