Java 使用引导在部署时创建目录
我需要在部署web应用程序时创建一个目录。此目录将包含所有用户的ProfilePic 代码: 结果: 创建目录配置文件图片失败。。 他使用的路径:C:/apache-tomcat-7.0.6/webapps/spring-1/webapps/profilePictures 我需要的是: 在此路径上创建dir profilePictures ->C:/apache-tomcat-7.0.6/webapps/spring-1/profilePictures spring-1是应用程序上下文 替换Java 使用引导在部署时创建目录,java,spring,tomcat,bootstrapping,dir,Java,Spring,Tomcat,Bootstrapping,Dir,我需要在部署web应用程序时创建一个目录。此目录将包含所有用户的ProfilePic 代码: 结果: 创建目录配置文件图片失败。。 他使用的路径:C:/apache-tomcat-7.0.6/webapps/spring-1/webapps/profilePictures 我需要的是: 在此路径上创建dir profilePictures ->C:/apache-tomcat-7.0.6/webapps/spring-1/profilePictures spring-1是应用程序上下文 替换 "
"/profilePictures"
与
您可以简单地执行以下操作:
boolean mkDir = new File(
sce.getServletContext().getRealPath("/profilePictures")).mkdir();
"/../profilePictures"
boolean mkDir = new File(
sce.getServletContext().getRealPath("/profilePictures")).mkdir();