【问题标题】:Error JSF 2.1: java.io.FileNotFoundException:*/*.xhtml Not Found in ExternalContext错误 JSF 2.1:java.io.FileNotFoundException:*/*.xhtml 在 ExternalContext 中未找到
【发布时间】:2011-11-28 13:55:00
【问题描述】:

我在 Jboss 7.0.2“Arc”中出现错误,spring webflow 2.3.0.RELEASE with richfaces 4.0.0.Final(Myfaces 2.1.1):

12:34:19,729 SEVERE [org.apache.myfaces.renderkit.ErrorPageWriter] (http--127.0.0.1-8080-2) 发生异常:javax.faces.FacesException: java.io.FileNotFoundException: /sections /login/header.xhtml 在 ExternalContext 中找不到作为资源。

当我运行我的 login.xhtml 页面时:

<ui:composition template="/WEB-INF/flows/template/default.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich">

<ui:define name="windowTitle">
#{msgs.loginTitle}
</ui:define>

<ui:define name="heading">
<ui:include src="/sections/login/header.xhtml"/>
</ui:define>

<ui:define name="sidebarLeft">
<ui:include src="/sections/login/sidebarLeft.xhtml"/>
</ui:define>

<ui:define name="content">
<h:form>
   <h:panelGrid columns="2">
      #{msgs.namePrompt}
      <h:inputText id="name" value="#{user.name}"/>
      #{msgs.passwordPrompt}
      <h:inputSecret id="password" value="#{user.password}"/>
   </h:panelGrid>
   <p>
      <h:commandButton value="#{msgs.loginButtonText}"
                       action="planetarium"/>
   </p>
</h:form>
</ui:define>

header.xhtml的代码是:

  <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"> 
  <!--  <head><title>IGNORED</title></head> -->
  <body>
  <ui:composition>
     <div class="header">
        #{msgs.loginHeading}
     </div>
  </ui:composition>
  </body>
  </html>

结构文件是这样的:

WEB-INF/flows/inscripcion
    inscripcion-flow.xhtml 
    inscripcion.xhtml    
    login.xhtml

WEB-INF/flows/sections/login
    header.xhtml
    sidebarLeft.xhtml

WEB-INF/flows/template
    template.xhtml

为什么会出现这个错误?,我附上了我的 Jboss 提示

https://rapidshare.com/files/817066879/log12.zip 谢谢。

【问题讨论】:

    标签: spring jsf-2 richfaces spring-webflow-2


    【解决方案1】:

    您似乎已将其放在WEB-INF/flows/sections/login/header.xhtml 中。相应地修复src 以匹配此内容。

    <ui:include src="/WEB-INF/flows/sections/login/header.xhtml"/>
    

    【讨论】:

    • Thnks,这对我有用,还有另一种方法可以调用 this(header.xhtml)??,这在 WEB-INF 中是正确的,因为在 JEE 6 教程中说:Web资源是 Web 应用程序正确呈现所需的任何软件工件,包括图像、脚本文件和任何用户创建的组件库。资源必须收集在标准位置,可以是以下位置之一。打包在 Web 应用根目录中的资源必须位于 Web 应用根目录的资源目录的子目录中:resources/resource-identifier。
    • 和 打包在 Web 应用程序类路径中的资源必须位于 Web 应用程序内 META-INF/resources 目录的子目录中:META-INF/resources/resource-identifier。
    • 另一种方法是使用相对于当前模板的路径(即不要以 / 开头)。但这不推荐。资源是CSS、JS、图片等静态文件,模板可以完美的放在/WEB-INF。它使它们无法直接访问(您无法通过网络浏览器打开 http://localhost:8080/contextname/WEB-INF/* 文件)。
    猜你喜欢
    • 2021-06-02
    • 2011-10-09
    • 2012-10-20
    • 2015-01-01
    • 2014-01-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-29
    • 1970-01-01
    相关资源
    最近更新 更多