Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在webapp文件夹中动态添加.xhtml文件_Java_Jsf_Jakarta Ee_Glassfish 3_Filewriter - Fatal编程技术网

Java 在webapp文件夹中动态添加.xhtml文件

Java 在webapp文件夹中动态添加.xhtml文件,java,jsf,jakarta-ee,glassfish-3,filewriter,Java,Jsf,Jakarta Ee,Glassfish 3,Filewriter,我想在我的项目的webapp文件夹中动态添加新的.xhtml文件。 只有当我给出完整的路径时,它才会起作用 FileWriter fw = new FileWriter("D:/projects/UIBindingExample/src/main/webapp/pagefour.xhtml"); fw.write("<html>...some code....</html>"); fw.close(); 我试过了,但没用

我想在我的项目的webapp文件夹中动态添加新的
.xhtml
文件。 只有当我给出完整的路径时,它才会起作用

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

            fw.close();
我试过了,但没用。!!! 我该怎么办?
在adv.

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

其中,
您的工件名称
是生成的WAR文件的名称


希望对您有所帮助。

然后按照以下路径创建文件
D:\program\glassfish-3.1.1\glassfish\domains\domain1
取决于您运行Web应用程序的位置或方式。我假设您使用的是通过Maven运行的嵌入式容器,比如jetty:run
src/main/webapp/pagefour.xhtml