错误:在外部上下文中找不到/login.xhtml作为资源 [英] Error: /login.xhtml Not Found in ExternalContext as a Resource

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

问题描述

我将JBoss 7.1与JSF 2.1/Prime Faces结合使用,并继续遇到标题中列出的错误.我尝试了这里提出的许多建议,但都以相同的错误告终.

I'm using JBoss 7.1 with JSF 2.1/Prime Faces and keep running into the error listed in the title. I've tried many of the suggestions made here and all end up with the same error.

文件结构为:

WEB-INF
   faces
      login.xhtml

我在web.xml中具有以下内容:

I have the following in web.xml:

<display-name>clientAccountManager</display-name>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

我正在使用以下URL访问文件:

I am accessing the file currently using the following URL:

http://localhost:8080/clientAccountManager/faces/login.xhtml

我还将URL模式更改为* .xhtml并使用了:

I have also changed the URL pattern to *.xhtml and used:

http://localhost:8080/clientAccountManager/login.xhtml

具有相同的结果.

我想念什么?

推荐答案

您犯了2个错误.

  1. /WEB-INF文件夹用于配置文件,包括文件,模板文件,标记文件等,这些文件应被隐藏以防止直接访问,而不是可公开访问的文件.将可公开访问的文件放在/WEB-INF文件夹之外.

  1. /WEB-INF folder is for configuration files, include files, template files, tag files, etc, which are supposed to be hidden from direct access, not for publicly accessible files. Put publicly accessible files outside /WEB-INF folder.

/faces文件夹. FacesServlet上的虚拟/faces/* URL模式并不意味着您应该具有这样的物理文件夹.删除它.

/faces folder should not be used at all. A virtual /faces/* URL pattern on FacesServlet doesn't imply that you should have a physical folder like that. Remove it.

所以,所有一切都只是

WebContent
 |-- META-INF
 |-- WEB-INF
 |    |-- faces-config.xml
 |    `-- web.xml
 `-- login.xhtml

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

http://localhost:8080/clientAccountManager/login.xhtml

应该做.

这篇关于错误:在外部上下文中找不到/login.xhtml作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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