在ExternalContext中找不到/index.xhtml作为资源 [英] /index.xhtml Not Found in ExternalContext as a Resource

查看:95
本文介绍了在ExternalContext中找不到/index.xhtml作为资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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-INFWEB-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆