Browse Source

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@671 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 years ago
parent
commit
6a5a0091dd
1 changed files with 13 additions and 6 deletions
  1. 13 6
      src/main/java/com/uas/platform/b2b/core/util/PathUtils.java

+ 13 - 6
src/main/java/com/uas/platform/b2b/core/util/PathUtils.java

@@ -1,6 +1,8 @@
 package com.uas.platform.b2b.core.util;
 package com.uas.platform.b2b.core.util;
 
 
 import java.io.File;
 import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 
 
 /**
 /**
  * 路径
  * 路径
@@ -50,13 +52,18 @@ public class PathUtils {
 	}
 	}
 
 
 	private static void setClassPath() {
 	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() {
 	private static void setAppPath() {