2012-04-20 79 views
0

我正在嘗試在其網站上製作一個簡單的PrimeFaces示例,如教程。我基本上有與this user完全相同的問題,但我沒有像他那樣的空的jar文件。 h:標籤渲染正常,但p:標籤在HTML中顯示爲p:標籤。 PrimeFaces 3.1.1和3.2的相同問題。這是我的web.xml文件。Primefaces標籤在Eclipse Facelets項目中未被識別

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
    <display-name>jsf</display-name> 
    <welcome-file-list> 
    <welcome-file>Login.xhtml</welcome-file> 
    </welcome-file-list> 
    <context-param> 
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> 
    <param-value>resources.application</param-value> 
</context-param> 
    <context-param> 
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description> 
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name> 
    <param-value>client</param-value> 
    </context-param> 
    <context-param> 
    <description></description> 
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name> 
<param-value>true</param-value> 
    </context-param> 
<context-param> 
<description></description> 
<param-name>org.apache.myfaces.PRETTY_HTML</param-name> 
<param-value>true</param-value> 
</context-param> 
    <context-param> 
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name> 
<param-value>false</param-value> 
</context-param> 
<context-param> 
    <description></description> 
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> 
<param-value>true</param-value> 
</context-param> 
<listener> 
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener- class> 
</listener> 
<servlet> 
    <servlet-name>Faces Servlet</servlet-name> 
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>Faces Servlet</servlet-name> 
<url-pattern>*.xhtml</url-pattern> 
</servlet-mapping> 
</web-app> 

我的XHTML文件看起來像這樣。

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui"> 
<h:head> 
    <title><ui:insert name="title">Facelets Tutorial</ui:insert></title> 
</h:head> 
<body> 
    <p:editor /> 
    <p:spinner /> 
</body> 
</html> 

我開始了我的服務器(Tomcat的6)和呈現的HTML看起來像這樣,H:標籤呈現精緻和p:標籤仍然號碼:標籤。

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.org/ui"><head> 
    <title>Facelets Tutorial</title></head> 
<body> 
    <p:editor></p:editor> 
    <p:spinner></p:spinner> 
</body> 
</html> 

我加入了PrimeFaces罐子到我的構建路徑,我知道它是被認可的,因爲我可以導入/使用PrimeFaces類只是在我的源文件的罰款。我甚至下載了PF源並將其添加到我的項目中以確保可以看到它,而且我仍然有這個問題。我的web.xml中是否需要一些額外的配置?

回答

5

構建路徑與否,您需要確保PrimeFaces JAR文件最終在構建和部署的WAR文件的/WEB-INF/lib文件夾中結束。症狀表明情況並非如此。

在Eclipse中,這只是直接在Web項目結構的/WEB-INF/lib文件夾中放置PrimeFaces JAR文件的問題。沒有其他事情需要去做; Eclipse將自動將其添加到構建路徑和部署程序集。在嘗試安裝PrimeFaces之前,不要忘記撤消在構建路徑中所做的所有更改。

如果你真的堅持保留JAR其他地方手動管理出於某種原因,構建路徑,那麼你需要在項目屬性的部署大會部分手動添加它,以及得到它的最終最終在WAR的/WEB-INF/lib文件夾中。

+0

這結束了爲我工作,謝謝! – json4639 2012-04-23 02:59:09

2

你應該使用「h:body」而不僅僅是「body」。

+0

是的,我看到後,我發佈的問題,但更改身體標籤也無法正常工作。 – json4639 2012-04-21 00:05:17