我正在 Eclipse 4.3 上使用 PrimeFaces 3.5 开发 JSF Web 应用程序。没有编译时或运行时错误,并且应用程序部署成功。但是,我无法在浏览器中获得所需的输出。 PrimeFaces 组件不会显示,而标准 JSF 组件会显示。
我不确定我的配置是否正确。 PrimeFaces JAR 至少在里面/WEB-INF/lib
:
![enter image description here](https://i.stack.imgur.com/WcC4v.png)
PrimeFaces XML 命名空间声明为xmlns:p="http:\\primefaces.org\ui"
![enter image description here](https://i.stack.imgur.com/y8670.png)
我映射了FacesServlet
on *.xhtml
:
![enter image description here](https://i.stack.imgur.com/gcZ2t.png)
这是完整的源代码login.xhtml
:
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p=" http://primefaces.org/ui" >
<h:body>
<h:head ><title>Login Page !!</title></h:head>
<h:form>
<p:panel id="panel" header="Login Panel" style="margin-bottom:10px;">
<h:panelGrid columns="3">
<h:outputLabel value="User Id:" />
<p:inputText id="id" value="loginBean.id" required="true" requiredMessage="ID required"/>
<p:message for="id" />
<p:outputLabel value="User Name:" />
<p:inputText id="name" value="loginBean.name" required="true" requiredMessage="Name required" />
<p:message for="name" />
</h:panelGrid>
</p:panel>
<p:commandButton type="Submit" value="Submit" action="#" style="margin-right:20px;" />
`
输出如下所示:
![enter image description here](https://i.stack.imgur.com/8I8Yl.png)
如你所见,<h:outputText>
完成了它的工作,但没有一个<p:xxx>
出现。这是如何引起的以及如何解决?
这不是直接回答这个问题,但与之相关。我想分享我对“PrimeFaces 标签未渲染”问题的经验。我正在 WildFly 上开发 JSF 2.2 应用程序,这是我的 index.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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<h:form>
<p:editor value="#{mDb.newMessage.content}"></p:editor>
</h:form>
</h:body>
</html>
当应用程序运行时,编辑器不会出现,这对我来说很奇怪,因为 PrimeFaces 在项目中配置正确。
我无意中发现了问题的原因。没有一个h:head
index.xhtml 中的标记。当我放置 head 标签时,PrimeFaces 组件渲染成功!
我希望这可以帮助某人。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)