1

我想.xhtml在我的项目的 webapp 文件夹中动态添加新文件。它仅在我给出完整路径时才有效,例如,

FileWriter fw = new FileWriter("D:/projects/UIBindingExample/src/main/webapp/pagefour.xhtml");
            fw.write("<html>...some code....</html>");

            fw.close();

而不是这个,我想使用文件的相对路径让它工作,比如,

src/main/webapp/pagefour.xhtml

我试过这个。但它不工作.!!! 我应该怎么办?谢谢你的建议。

4

1 回答 1

0

src/main/webapp/pagefour.xhtml是您的 webapp 上下文的相对路径,因此如果您运行此代码,您最终可能会将文件内容保存到D:/projects/UIBindingExample/target/your-artifact-name/WEB-INF/main/webapp/pagefour.xhtml

其中your-artifact-name是生成的 WAR 文件的名称。

希望有帮助。

于 2012-01-19T08:37:30.207 回答