在ExternalContext中找不到/index.xhtml作为资源 [英] /index.xhtml Not Found in ExternalContext as a Resource
问题描述
我的JSF Web应用程序显示以下错误:
My JSF web application shows the following error:
/index.xhtml在ExternalContext中找不到作为资源.
/index.xhtml Not Found in ExternalContext as a Resource.
我的目录结构是:
- Java Resource
-- src
--- br.com.k19.controle
---- NumeroAleatorioBean.java
--- resources
- JavaScript Resources
- build
- WebContent
-- META-INF
-- Web Pages
--- index.xhtml
--- formulario.xhtml
-- Web-Inf
我需要将/index.xhtml
放在哪里?
推荐答案
WebContent
文件夹代表Web内容.您将index.xhtml
文件放置在Web Pages
子文件夹中,以便正确的URL为
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
,因此不是
http://localhost:8080/ProjectName/index.xhtml
如您所料.
如果要在上下文根目录中保存它,只需完全删除Web Pages
文件夹,然后将这些.xhtml
文件直接移到WebContent
文件夹中即可,与META-INF
和WEB-INF
处于同一级别:
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
注意:Java区分大小写. Web-Inf
绝对不同于WEB-INF
.请当心,否则您将遇到安全漏洞.
Note: Java is case sensitive. Web-Inf
is definitely not the same as WEB-INF
. Be careful or you'll have a security hole.
这篇关于在ExternalContext中找不到/index.xhtml作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!