gpt4 book ai didi

eclipse - 尽管存在依赖关系,PrimeFaces 组件不会在浏览器中呈现

转载 作者:行者123 更新时间:2023-12-02 20:58:27 25 4
gpt4 key购买 nike

我正在 Eclipse 4.3 上使用 PrimeFaces 3.5 开发 JSF Web 应用程序。没有编译时或运行时错误,并且应用程序部署成功。但是,我无法在浏览器中获得所需的输出。 PrimeFaces 组件不会显示,而标准 JSF 组件会显示。

我不确定我的配置是否正确。 PrimeFaces JAR 至少在 /WEB-INF/lib 内:

enter image description here

PrimeFaces XML 命名空间声明为 xmlns:p="http:\\primefaces.org\ui"

enter image description here

我映射了 FacesServlet*.xhtml :

enter image description here

这是 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

如您所见,<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 在项目中配置正确。

我无意中发现了问题的原因。 index.xhtml 中没有 h:head 标记。当我放置 head 标签时,PrimeFaces 组件渲染成功!!

我希望这可以帮助别人。

关于eclipse - 尽管存在依赖关系,PrimeFaces 组件不会在浏览器中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18462568/

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