String path = new DefaultResourceLoader().getClassLoader().getResource("/").getPath();
path = URLDecoder.decode(path);
if (path.endsWith("/")) {
return path.substring(0, path.length() - 1);
} else {
return path;
}
path = URLDecoder.decode(path);
if (path.endsWith("/")) {
return path.substring(0, path.length() - 1);
} else {
return path;
}
本文详细介绍了如何使用Java的DefaultResourceLoader类获取资源路径,并通过URLDecoder解码路径字符串。重点阐述了如何判断路径是否以斜杠结尾,以及相应的路径处理方法。
4082

被折叠的 条评论
为什么被折叠?



