读书人

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

发布时间: 2012-07-25 09:43:06 作者: rapoo

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

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");

读书人网 >软件架构设计

热点推荐