Java 在webapp文件夹中动态添加.xhtml文件
我想在我的项目的webapp文件夹中动态添加新的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(); 我试过了,但没用
.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