獲取類文件所在的真實路徑 1.this.getClass().getClassLoader().getResource("/").getPath(); 2.this.getClass().getResource("/").getPath(); 注意:1.如果文件不存在的話,將會發(fā)生nullpointerException 2.如果想獲取web-inf/classes的路徑,可以通過"/."獲取
獲取web服務器所在的真實路徑 request.getContextPath();
Powered by: BlogJava Copyright © xiachang88