我需要在部署我的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是在应用程序上下文