0

Web アプリケーションをデプロイするときにディレクトリを作成する必要があります。このディレクトリには、すべてのユーザーのプロフィール写真が含まれます。

コード:

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/webapps/spring-1/webapps/profilePictures

  • 必要なもの: このパスでのディレクトリ (「profilePictures」) の作成 -> C:/apache-tomcat-7.0.6/webapps/spring-1/profilePictures

  • spring-1 はアプリケーションコンテキストです

4

2 に答える 2

0

交換

"/profilePictures"

"/../profilePictures"
于 2011-02-10T09:29:43.430 に答える
0

これを簡単に行うことができます:

boolean mkDir = new File(
    sce.getServletContext().getRealPath("/profilePictures")).mkdir(); 
于 2011-02-10T09:40:31.113 に答える