1. 程式人生 > >tomcat 和 weblogic獲取專案的根路徑的方法

tomcat 和 weblogic獲取專案的根路徑的方法

web專案中tomcat weblogic都支援的寫法 :

嘗試用其他方法獲取的時候 在linux下的weblogic會獲取成空   

    String path = this.getClass().getClassLoader().getResource("/").getPath();

    String realPath = path.substring(0, path.length() - 17);