/index.xhtml Not Found in ExternalContext as a Resource

主宰稳场 提交于 2019-12-18 13:14:37

问题


My JSF web application shows the following error:

/index.xhtml Not Found in ExternalContext as a Resource.

My directory structure is:

- Java Resource
-- src
--- br.com.k19.controle
---- NumeroAleatorioBean.java
--- resources
- JavaScript Resources
- build
- WebContent
-- META-INF
-- Web Pages
--- index.xhtml
--- formulario.xhtml
-- Web-Inf

Where do I need to put my /index.xhtml in this structure?


回答1:


The WebContent folder represents the web content. You placed the index.xhtml file inside Web Pages subfolder so the right URL would be

http://localhost:8080/ProjectName/Web Pages/index.xhtml

and thus not

http://localhost:8080/ProjectName/index.xhtml

as you seemed to expect.

If you want to have it on the context root, just get rid of the Web Pages folder altogether and move those .xhtml files directly inside WebContent folder, in the same level as META-INF and WEB-INF:

ProjectName
 |-- Java Resources
 |    `-- src
 |         `-- br.com.k19.controle
 |              `-- NumeroAleatorioBean.java
 |-- resources
 |-- JavaScript Resources
 |-- build
 `-- WebContent
      |-- META-INF
      |-- WEB-INF
      |    |-- faces-config.xml
      |    `-- web.xml
      |-- index.xhtml
      `-- formulario.xhtml

Note: Java is case sensitive. Web-Inf is definitely not the same as WEB-INF. Be careful or you'll have a security hole.




回答2:


I faced this issue recently. I tried cleaning the Tomcat Work Directory, Clean, and Publish. After that, when I started the server, the application was running smooth.

For independent tomcat server, clean dir --> temp, work, and inside webApp directory, remove all the existing unarchived project. Restart the Tomcat, it worked for me.



来源:https://stackoverflow.com/questions/19714598/index-xhtml-not-found-in-externalcontext-as-a-resource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!