2013-11-23 25 views
0

在第二個瀏覽器中使用IFRAME menuBar時,出現com.sun.faces.context.FacesFileNotFoundException。在XHTML中使用IFrame時FacesFileNotFoundException

我在使用其他瀏覽器時出現此錯誤。

HTTP Status 500 - 

type Exception report 

message 

description The server encountered an internal error() that prevented it from fulfilling this request. 
- 

exception 

com.sun.faces.context.FacesFileNotFoundException: /xhtml/auth/faces/xhtml/client/clientImage.xhtml Not Found in ExternalContext as a Resource 
    com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:232) 
    com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:273) 
    com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:209) 
    com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:114) 
    com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233) 
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
    com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) 
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) 
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) 
    com.beo.importexport.filter.AuthFilter.doFilter(AuthFilter.java:64) 
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) 
note The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs. 

JBoss Web/7.0.13.Final: 

我在一個XHTML頁面中使用了templage。 在模板內部使用IFrame。

iframe由帶有一些菜單項的菜單欄組成。

我的問題是,當登錄到第二個Web瀏覽器時,會話發生變化,因此IFRAME中的SRC將前綴到hardcorded路徑的較早路徑。

下面

 <iframe name="contentframe" id="contentframe" 
      width="100%" height="710px" 
    src="faces/xhtml/client/clientImage.xhtml" 
      scrolling="auto" 
      style="overflow: auto;" > 
    </iframe> 

我的IFRAME SRC標籤爲什麼這個路徑前綴發生在IFRAME SRC?

回答

0

這是因爲您的<iframe src>表示相對URL。它不以該方案開始(例如,http://,https://等),也不以斜槓(/)開頭。相對URL是相對於當前請求URL進行解釋的(在瀏覽器的地址欄中看到的;請注意:因此不適用於服務器磁盤文件系統中的物理文件位置,因爲許多啓動程序錯誤地認爲該位置)。

所以,如果請求的URL(猜測/faces是上下文路徑,你不就清楚了,你告訴一無所知上下文路徑也沒有實際的請求URL也不是JSF映射)例如,

http://example.com/faces/xhtml/auth/login.xhtml

那麼相對URL faces/xhtml/client/clientImage.xhtml將被搜索在當前請求URL的相同的文件夾,從而導致此URL:

http://example.com/faces/xhtml/auth/faces/xhtml/client/clientImage.xhtml

雖然仍然asusming是/faces是上下文路徑,那麼這將產生正是你得到了異常:你也完全iframe的文件是什麼網址不明確

com.sun.faces.context.FacesFileNotFoundException: /xhtml/auth/faces/xhtml/client/clientImage.xhtml Not Found in ExternalContext as a Resource 

可用。基於迄今爲止提供的資料,我最好的猜測是

http://example.com/faces/xhtml/client/clientImage.xhtml

如果事實確實如此,那麼你實際上應使用

<iframe src="/faces/xhtml/client/clientImage.xhtml" /> 

的斜線/會無論當前的請求URL如何,都要將其解釋爲相對於域根。

+0

感謝BalusC, 但我通過將路徑這樣