我正在嘗試使用Eclipse 3.6和Glassfish 3.1作爲應用程序服務器來啓動我的Primefaces 3.2開發。Primefaces標記無法正常工作
當我嘗試使用這個非常簡單的代碼從Eclipse發佈我的應用程序。
<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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="WEB-INF/template.xhtml">
<ui:define name="content">
<p:panel header="Login Form">
<h:form>
<p:button value="With Icon!" icon="bookmark" />
<br />
<p:spinner />
</h:form>
</p:panel>
</ui:define>
</ui:composition>
</html>
Primefaces不呈現。該按鈕顯示,但沒有圖標,微調器只顯示輸入文本。
不確定,但我已經將primefaces jar文件放在WEB-INF/lib文件夾中。
雖然我在glassfish日誌中看到這個錯誤。
[#|2012-04-17T11:37:56.864+0800|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.renderkit|_ThreadID=23;_ThreadName=Thread-2;|WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.), detail=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.)]|#]
更新:
對不起,這裏是我的web.xml
<?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_3_0.xsd"
version="3.0">
<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>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
我的模板
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<title><ui:insert name="title">My Test Application</ui:insert></title>
</head>
<body>
<div id="header">
<ui:insert name="header">
<h1>Header</h1>
</ui:insert>
</div>
<div id="content">
<ui:insert name="content">
</ui:insert>
</div>
<div id="footer">
<ui:insert name="footer">
<br/><br/>Footer!
</ui:insert>
</div>
</body>
</html>
錯誤消息表示您在視圖中缺少' '標記。嘗試添加它。您是否已將一些資源定位到「 」? –
Lion
2012-04-17 03:53:26
什麼在'web.xml'?你需要配置'FacesServlet',就像在[這個問題]中一樣(http://stackoverflow.com/q/3599015/139010)。 – 2012-04-17 04:00:32
問題是獅子提到的。在你的模板中輸入''。這將啓用primefaces javascript呈現。 –
2012-04-17 04:02:46