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