gpt4 book ai didi

java - Primefaces 标签不起作用

转载 作者:行者123 更新时间:2023-11-30 07:26:46 24 4
gpt4 key购买 nike

我正在尝试使用 Eclipse 3.6 和 Glassfish 3.1 作为应用服务器来快速启动我的 Primefaces 3.2 开发。

当我尝试使用这个非常简单的代码从 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>

最佳答案

您需要在 template.xhtml 文件中进行以下更改,例如

<f:view>
<h:head>
<title><ui:insert name="title">insert title</ui:insert></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-type" />
<link type = "text/css" rel="stylesheet" href="/your/theme/skin.css" />
</h:head>

希望对您有所帮助。

关于java - Primefaces 标签不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10184760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com