繁体   English   中英

在ExternalContext中找不到/index.xhtml作为资源

[英]/index.xhtml Not Found in ExternalContext as a Resource

我的JSF Web应用程序显示以下错误:

在/ ExternalContext中找不到/index.xhtml作为资源。

我的目录结构是:

- 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为

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

因此没有

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

如您所料。

如果要在上下文根目录中放置它,只需完全删除Web Pages文件夹,然后将那些.xhtml文件直接移到WebContent文件夹中,与META-INFWEB-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 请当心,否则您将有安全漏洞。

我最近遇到了这个问题。 我尝试清理Tomcat Work Directory,然后清理发布 之后,当我启动服务器时,应用程序运行平稳。

对于独立的tomcat服务器,请清理dir-> temp,work,并在webApp目录中, 删除所有现有的未归档项目。 重新启动 Tomcat,它对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM