【问题标题】:index.xhtml resource not found in JSF在 JSF 中找不到 index.xhtml 资源
【发布时间】:2018-08-01 16:01:37
【问题描述】:

我在我的 JSF 2.2 应用程序的 WebContent 文件夹中创建了一个空白的 .xhtml 页面。我尝试运行该应用程序,但收到 404 - 未找到请求。

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>Vijesti</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
</web-app>

它在 5 分钟前确实有效,但现在无效。它也不适用于/faces/*

编辑:这是我的 index.xhtml 文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:body>

</h:body>

</html>

它位于 WebContent 文件夹中。

【问题讨论】:

  • 也许你删除了页面???请提供更多信息...
  • @Kukeltje 我没有,它在 WebContent...
  • 您的应用程序可能有另一个问题,因此它没有部署在您的服务器上。服务器启动过程中是否有任何错误?您如何尝试在浏览器中调用您的索引文件?

标签: jsf xhtml


【解决方案1】:

您应该将文件添加到欢迎文件列表中。我假设您的 xhtml 称为 index.xhtml。试试

<welcome-file>index.xhtml</welcome-file>

【讨论】:

  • 不,这不是必需的...仅当您希望它成为索引文件时。即便如此,它也不会导致 404
猜你喜欢
  • 2013-11-11
  • 1970-01-01
  • 2016-02-10
  • 1970-01-01
  • 2013-07-30
  • 2016-12-25
  • 1970-01-01
  • 2014-02-17
  • 2014-12-01
相关资源
最近更新 更多