我需要在部署我的Web應用程序時創建一個目錄。這個目錄將包含所有用戶的profilepics。使用引導程序創建目錄
代碼:
public class ImageBootstrapper {
public static void initialise(ServletContextEvent sce) {
boolean mkDir = new File(sce.getServletContext().getRealPath("webapps").replace('\\','/') + "/profilePictures").mkdir();
}
}
結果: 該目錄的創建( 「profilePictures」)失敗.. 路徑,他使用:C:/apache-tomcat-7.0.6/ web應用/彈簧-1/web應用/ profilePictures
我需要: 創作迪爾的( 「profilePictures」)在此路徑 - > C:/apache-tomcat-7.0.6/webapps/spring-1/profilePictures
彈簧-1是在應用程序上下文