获取应用根目录有空格的问题

root=this.getClass().getClassLoader().getResource("../../WEB-INF").getPath();

root=/D:/Program%20Files/server/webapps/study/WEB-INF/

在程序中获取到应用的根目录时,如果server存放的目录中带有空格的解决办法:

方法1.把目录中的空格去掉。。。。

方法2:root = URLDecoder.decode(this.getClass().getClassLoader().getResource("../../WEB-INF").getPath(), "utf-8");

猜你喜欢

转载自hngmduyi.iteye.com/blog/1508642