获取项目路径出现%20的问题
String path = FileUtil.class.getClassLoader().getResource(SPECIAL_USER_FILE).getPath();
try {
path = URLDecoder.decode(path,"UTF-8");//针对tomcat路径有空格,进行处理
} catch (UnsupportedEncodingException e) {
System.out.println("文件路径处理错误!");
}
获取项目路径的方式
request.getServletContext().getRealPath("");
//XXXClass 是项目中任意的class
XXXClass.class.getClassLoader().getResource("").getPath();