简体   繁体   English

welcome-file index.xhtml提供“在ExternalContext中找不到”作为资源

[英]welcome-file index.xhtml gives Not Found in ExternalContext as a Resource

I have a jsf project which deployed to wildfly 10 server . 我有一个jsf项目,已部署到wildfly 10服务器。 After deployment I navigate to deployment root ( http://localhost:8080/ {deployment-name}/) get "/home/default.xhtml Not Found in ExternalContext as a Resource" error but when I navigate to file directly to file defined in web.xml as hello.xhtml ( http://localhost:8080/ {deployment-name}/hello.xhtml) everything works perfectly. 部署后,我导航到部署根目录( http:// localhost:8080 / {deployment-name} /)出现“ /home/default.xhtml在ExternalContext中找不到作为资源”错误,但是当我直接导航到文件到定义的文件时在web.xml中作为hello.xhtml( http:// localhost:8080 / {deployment-name} /hello.xhtml)可以正常运行。 I guess its something wrong with welcome-file-list I wonder how I can make deployment root to hello.xhtml ? 我猜想welcome-file-list出了点问题,我想知道如何使根目录部署到hello.xhtml吗? Thanks in advance. 提前致谢。 Here are the source files : web.xml : 以下是源文件: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>

and the file structure is : 文件结构为:

-main
--java
--resources
--webapp 
---hello.xhtml
---WEB-INF
----web.xml
----templates
------default.xhtml

And hello.xhtml file is : 而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>

and /WEB-INF/templates/default.xhtml is : 和/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>

I solve the issue . 我解决了这个问题。 It was pretty-config.xml caused. 这是由pretty-config.xml引起的。 The resouce files indicated in that file not found by the system. 系统找不到该文件中指示的资源文件。 pretty-config.xml 漂亮-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>

Thanks for every one. 谢谢大家

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM