2

我在 Ubuntu 上与 Tomcat 进行了部署战争。当我尝试创建文件夹时,未创建此文件夹。文件夹路径为 /orders/,Java 代码为:

File tmpDir = new File("/orders/1);
if (!tmpDir.exists()) {
        tmpDir.mkdir();
}

我有一个 try/catch,但会抛出任何异常。

我的文件夹的权限是:

drwxrwxrwx   2 root root  4096 May 28 20:51 orders

并尝试显示执行 Tomcat 的用户,我可以看到它是 root:

pas aux | grep apache

root     26890  1.2  3.4 4507084 412560 pts/7  Sl   20:46   0:14 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties .....

当我查看这个文件夹时,我什么都看不到...

问题是什么?

Tomcat权限?我在哪里可以看到?或者也许我在 web.xml 或某个地方没有路径?

@Harald 的解决方案:

在 Java 7 中,使用 Files.createDirectories() 比使用 mkdir() 更好。Mkdir 对我不起作用。

4

0 回答 0