2013-06-01 87 views
0

我只用一個頁面index.xhtml(eclipse juno 4.2 + JBoss AS 7.1)製作了基本的動態web項目。當我運行我的網頁時,瀏覽器只顯示html元素而不是jsf。我的index.xhtml代碼:不顯示jsf元素

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title></title> 
</head> 
<body> 
push the button: 
<button>ok</button> 
<h:button value="not ok"></h:button> 
</body> 
</html> 

我只能看到「ok」按鈕。 當我開始我的服務器(獨立的)我已經警告說:

WARN [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor' for service type 'com.sun.faces.spi.injectionprovider' 
WARN [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection' for service type 'com.sun.faces.spi.injectionprovider' 
WARNING [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) JSF1069: Disabling the JSF 2.0 Facelets ViewHandler as an older FaceletViewHandler, com.sun.facelets.FaceletViewHandler, has been explicitly configured. If this is not desired behavior, remove the older FaceletViewHandler and library from your application. 

假如任何人同樣的問題?我犯了錯誤,或者IDE或服務器有一些錯誤? 感謝您的幫助。

我有另一個問題。我想添加庫主面。我右鍵單擊項目然後屬性 - >部署程序集 - >添加和.jar顯示在管理窗口中,但庫不出現在文件層次結構(WEB-INF/lib)中。

回答

3

你的webapp的運行時類路徑是一團糟。在日誌的最後警告已經是全部答案:

JSF1069:禁用JSF 2.0的Facelets的ViewHandler作爲一個大FaceletViewHandler,com.sun.facelets.FaceletViewHandler,已明確配置。如果這不是所期望的行爲,請從應用程序中刪除舊的FaceletViewHandler和庫。

你這本身已經因某種原因從Facelets的1.x的一個jsf-facelets.jar文件在你的web應用的運行時類路徑(如com.sun.facelets包裝標識),當你使用JSF 2.0已經打包的Facelets 2.X(如com.sun.faces.facelets包所示)。

擺脫jsf-facelets.jar以及您的webapp的運行時類路徑中的其他JSF 1.x相關構件(以及/WEB-INF/lib文件夾覆蓋的其他文件)。停止閱讀JSF 1.x有針對性的書籍/教程/資源,並前往JSF 2.x版本。在JSF 2.x中,許多事情都做了不同的處理,所以依賴JSF 1.x資源只會陷入混亂和麻煩之中。

在已經捆綁了JSF 2.x的JBoss 7上,在/WEB-INF/lib中不需要任何JAR。你也不需要把任何東西放在faces-config.xml。如果您使用的是JSF 2.1並依賴*.jsf的默認URL映射,那麼您也不需要將任何東西放入web.xml。所以這兩個文件可以有效地保持空白。