2012-05-27 52 views
1

我之前在這裏發佈了關於如何爲兩個使用jsf的用戶製作一個tic tac腳趾,並且獲得了這個偉大的taglib Primefaces的鏈接。對於我需要做的事情來說,這絕對是完美的,但是我一直在試圖讓它做任何事情,甚至從他們的網站上呈現示例。tomcat上的Primefaces標籤庫,從一個有效的jsp文件中渲染一個空的頁面

所以,我一直在關注這個教程中,我發現了(遺憾的是,目前還沒有關於Primefaces的主題很多人):http://java.dzone.com/articles/primefaces-quickstart-tutorial 一步一步來,我按照這個教程做的一切,但是當我運行它,它每次都會呈現一個空白頁面。

所以,我想從官方網站一個簡單的例子:http://www.primefaces.org/gettingStarted.html

這(test.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:p="http://primefaces.org/ui"> 
    <h:head> 
    </h:head> 
<h:body>  
<p:spinner /> 
</h:body> 
</html> 

呈現一個空白頁面,而這一點:

<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:p="http://primefaces.org/ui"> 
    <h:head> 
    </h:head> 
<h:body> 
test test test test 
<p:spinner /> 
</h:body> 
</html> 

呈現只有「測試測試測試」文字。

所以我想問題一定是在標籤中,tomcat不會看到它們/不知道如何解釋它們。 但是,根據教程和primefaces網站,我所需要做的就是像我一樣將jar放入WEB-INF/lib中(順便說一下,我使用的是Eclipse,我創建的空項目是「Dynamic Web項目「)。 在我的WEB-INF/lib中,我有以下罐子:

JSF-API-2.0.3.jar

JSF-IMPL-2.0.3.jar

JSTL-1.0.2。罐子

primefaces-3.3.RC1.jar

如果它的任何幫助,這裏的tomcat的控制檯的內容:

2012-05-27 13:18:11 org.apache.catalina.core.AprLifecycleListener init 
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in       production environments was not found on the java.library.path:   .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java 
    2012-05-27 13:18:12 org.apache.tomcat.util.digester.SetPropertiesRule begin 
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Primefaces1' did not find a matching property. 
    2012-05-27 13:18:12 org.apache.coyote.http11.Http11Protocol init 
    INFO: Initializing Coyote HTTP/1.1 on http-8080 
    2012-05-27 13:18:12 org.apache.catalina.startup.Catalina load 
    INFO: Initialization processed in 1127 ms 
    2012-05-27 13:18:12 org.apache.catalina.core.StandardService start 
    INFO: Starting service Catalina 
    2012-05-27 13:18:12 org.apache.catalina.core.StandardEngine start 
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.35 
    2012-05-27 13:18:13 com.sun.faces.config.ConfigureListener contextInitialized 
    INFO: Initializing Mojarra 2.0.3 (SNAPSHOT 20100726) for context '/Primefaces1' 
    2012-05-27 13:18:17 org.primefaces.webapp.PostConstructApplicationEventListener processEvent 
    INFO: Running on PrimeFaces 3.3.RC1 
    2012-05-27 13:18:17 org.apache.coyote.http11.Http11Protocol start 
    INFO: Starting Coyote HTTP/1.1 on http-8080 
    2012-05-27 13:18:17 org.apache.jk.common.ChannelSocket init 
    INFO: JK: ajp13 listening on /0.0.0.0:8009 
    2012-05-27 13:18:17 org.apache.jk.server.JkMain start 
    INFO: Jk running ID=0 time=0/63 config=null 
    2012-05-27 13:18:17 org.apache.catalina.startup.Catalina start 
    INFO: Server startup in 5096 ms 

可能是什麼情況?我是否把瓶子放在錯誤的地方,是tomcat失敗還是其他的東西?

回答

1

好吧,我解決了它,也許有人會有一天會覺得這有用。

所以,當在JSF中使用Primefaces時,不僅網頁文件必須具有.xhtml擴展名(我在這裏找到的解決方案:http://www.coderanch.com/t/473437/JSF/java/not-allowed-template-text),還必須修改web.xml文件(解決方案I在這裏找到了:Simple primefaces application not working),像這樣:

<servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name> 
    <url-pattern>*.xhtml</url-pattern> 
</servlet-mapping> 

現在它工作得很好。

+0

此問題與PrimeFaces並不嚴格相關,但與一般的基本JSF無關。不使用PrimeFaces時,您會遇到完全相同的問題。在瀏覽器的右鍵頁面*查看源代碼*中,當請求沒有調用'FacesServlet'時,您會看到像''等標準JSF標籤**也是** unparsed! – BalusC

+0

你可以一步一步解釋,如何使用JSF和primefaces來實現井字遊戲@Natalia Zon – spt

相關問題