且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:在外部上下文中找不到/login.xhtml作为资源

更新时间:2023-11-17 23:05:04

您犯了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

应该做.