简体   繁体   English

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

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

My JSF web application shows the following error: 我的JSF Web应用程序显示以下错误:

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

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? 我需要在哪里将/index.xhtml放在此结构中?

The WebContent folder represents the web content. WebContent文件夹代表Web内容。 You placed the index.xhtml file inside Web Pages subfolder so the right URL would be 您将index.xhtml文件放置在Web Pages子文件夹中,因此正确的URL为

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 : 如果要在上下文根目录中放置它,只需完全删除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

Note: Java is case sensitive. 注意:Java区分大小写。 Web-Inf is definitely not the same as WEB-INF . Web-Inf绝对不同于WEB-INF Be careful or you'll have a security hole. 请当心,否则您将有安全漏洞。

I faced this issue recently. 我最近遇到了这个问题。 I tried cleaning the Tomcat Work Directory, Clean , and Publish . 我尝试清理Tomcat Work Directory,然后清理发布 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. 对于独立的tomcat服务器,请清理dir-> temp,work,并在webApp目录中, 删除所有现有的未归档项目。 Restart the Tomcat, it worked for me. 重新启动 Tomcat,它对我有用。

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

相关问题 404 /index.xhtml在ExternalContext中找不到作为资源 - 404 /index.xhtml Not Found in ExternalContext as a Resource welcome-file index.xhtml提供“在ExternalContext中找不到”作为资源 - welcome-file index.xhtml gives Not Found in ExternalContext as a Resource com.sun.faces.context.FacesFileNotFoundException:/protected-area/index.xhtml在ExternalContext中找不到作为资源 - com.sun.faces.context.FacesFileNotFoundException: /protected-area/index.xhtml Not Found in ExternalContext as a Resource 在JSF中找不到index.xhtml资源 - index.xhtml resource not found in JSF 错误:在ExternalContext中找不到/login.xhtml作为资源 - Error: /login.xhtml Not Found in ExternalContext as a Resource 无法找到或提供资源,/ Directory1 / Myproject / index.xhtml - Unable to find or serve resource, /Directory1/Myproject/index.xhtml IntelliJ项目错误“在外部上下文中找不到/hello.xhtml作为资源” - IntelliJ project errors “/hello.xhtml Not Found in ExternalContext as a Resource” 错误:在ExternalContext中找不到/JavaServerFaces/default.xhtml作为资源 - Error: /JavaServerFaces/default.xhtml Not Found in ExternalContext as a Resource Primefaces 和 Jboss 的 index.xhtml 404 错误 - index.xhtml 404 error with Primefaces and Jboss <h:outputText> index.xhtml无法在浏览器中呈现 - <h:outputText> of index.xhtml not rendering in the browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM