Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 欢迎使用的文件index.xhtml在ExternalContext中未作为资源找到_Java_Jsf_Primefaces_Web.xml_Welcome File - Fatal编程技术网

Java 欢迎使用的文件index.xhtml在ExternalContext中未作为资源找到

Java 欢迎使用的文件index.xhtml在ExternalContext中未作为资源找到,java,jsf,primefaces,web.xml,welcome-file,Java,Jsf,Primefaces,Web.xml,Welcome File,我有一个部署到wildfly 10服务器的jsf项目。部署后,我导航到部署根({deployment name}/)get“/home/default.xhtml未作为资源在ExternalContext中找到”错误,但当我直接导航到web.xml中定义为hello.xhtml({deployment name}/hello.xhtml)的文件时,一切都正常工作。 我猜欢迎文件列表有问题 我想知道如何使部署根目录成为hello.xhtml? 提前谢谢。 以下是源文件: web.xml: <

我有一个部署到wildfly 10服务器的jsf项目。部署后,我导航到部署根({deployment name}/)get“/home/default.xhtml未作为资源在ExternalContext中找到”错误,但当我直接导航到web.xml中定义为hello.xhtml({deployment name}/hello.xhtml)的文件时,一切都正常工作。 我猜欢迎文件列表有问题 我想知道如何使部署根目录成为hello.xhtml? 提前谢谢。 以下是源文件: web.xml:

 <?xml version="1.0" encoding="ISO-8859-1" ?>
    <web-app version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"

    >
      <display-name>Archetype Created Web Application</display-name>

    <listener><listener-class>com.sun.faces.config.ConfigureListener</listener-class></listener>
        <!-- JSF mapping -->
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <!-- Map these files with JSF -->
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
            <welcome-file>/hello.xhtml</welcome-file>
        </welcome-file-list>
    </web-app>
hello.xhtml文件是:

  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"
        xmlns:f="http://xmlns.jcp.org/jsf/core"
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich"
        template="/WEB-INF/templates/default.xhtml">
        <ui:define name="content">
        <f:view>

        <h2>This is content</h2>
        </f:view>
        </ui:define>
    </ui:composition>

这就是内容
和/WEB-INF/templates/default.xhtml是:

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pretty="http://ocpsoft.com/prettyfaces"
      >
      <h:head>
      </h:head>
      <h:body>

       <div id="container">
        <div id="header">

        </div>
       <div id="content">
           <ui:insert name="content"></ui:insert>
       </div>
       <div id="footer">

       </div>
       </div>


        <div>

       </div>

      </h:body>
      </html>

我解决了这个问题。这是由pretty-config.xml引起的。系统找不到该文件中指示的资源文件。 pretty-config.xml

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

     <url-mapping id="view-home">
    <pattern value="/" />
    <view-id value="/home/default.xhtml" />
</url-mapping>
<url-mapping id="view-user">
    <pattern value="/user/#{username}" />
    <view-id value="/user/view.xhtml" />
</url-mapping>
<url-mapping id="record-edit">
    <pattern value="/record/edit" />
    <view-id value="/xhtml/record/edit.xhtml" />
</url-mapping>

</pretty-config>

谢谢大家

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

     <url-mapping id="view-home">
    <pattern value="/" />
    <view-id value="/home/default.xhtml" />
</url-mapping>
<url-mapping id="view-user">
    <pattern value="/user/#{username}" />
    <view-id value="/user/view.xhtml" />
</url-mapping>
<url-mapping id="record-edit">
    <pattern value="/record/edit" />
    <view-id value="/xhtml/record/edit.xhtml" />
</url-mapping>

</pretty-config>