今天遇到一个问题,当tomcat文件夹有空格,用类加载器获取路径时会将空格转换为20%..
解决办法将路径先用URL编码;
eg:
String path = CustFactory.class.getClassLoader().getResource("config.properties").getPath();改为
String path = CustFactory.class.getClassLoader().getResource("config.properties").toURI().getPath();