我刚刚完成了Netbeans对Hibernate教程(http://netbeans.org/kb/docs/web/hibernate-webapp.html#01)的介绍,我收到以下错误: “此页面调用使用前缀br声明的XML名称空间,但不存在taglibrary”
现在,我在其他地方看到过类似的问题: http://forums.sun.com/thread.jspa?threadID=5430327 但答案没有列在那里。或者,如果是,那么我显然错过了它 - 我的index.xhtml文件中的第一行显示为“http://www.w3.org/1999/xhtml”。它也没有解释为什么当我重新加载localhost:8080时,消息消失了。
这是我的index.xhtml文件:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="./template.xhtml">
<ui:define name="body">
<h:form>
<h:commandLink action="#{filmController.previous}" value="Previous #{filmController.pageSize}" rendered="#{filmController.hasPreviousPage}"/>
<h:commandLink action="#{filmController.next}" value="Next #{filmController.pageSize}" rendered="#{filmController.hasNextPage}"/>
<h:dataTable value="#{filmController.filmTitles}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="Title"/>
</f:facet>
<h:outputText value="#{item.title}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Description"/>
</f:facet>
<h:outputText value="#{item.description}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" "/>
</f:facet>
<h:commandLink action="#{filmController.prepareView}" value="View"/>
</h:column>
</h:dataTable>
<br/>
</h:form>
</ui:define>
</ui:composition>
</html>
答案 0 :(得分:4)
问题显然来自<br/>
标记,而facelets正试图将其解释为带有前缀的JSF / facelets标记。
如果我们遵循标准,则此标记应如下所示<br />
(斜杠前面有一个空格)。尝试这种方式,如果它不起作用,请尝试删除它。
答案 1 :(得分:3)
我迟了几年,但我刚刚完成了相同的Hibernate教程,并且遇到了完全相同的错误。但是,我不认为该问题与文件index.xhtml有关。虽然另一张海报是正确的,断点标签应该有一个空格,但这种改变不会阻止错误“此页面调用用前缀br声明的XML名称空间但不存在标记库”
问题在于名为 browse.xhtml 的教程中的另一个xhtml文件。您可以使用开头帖子中的教程链接查看该文件的内容。它包含一个不匹配的尾随&lt; / html&gt;标记,并且没有对http://www.w3.org/1999/xhtml命名空间的引用。
将该文件的内容粘贴到HTML验证器(例如validator.w3.org)中会突出显示问题。
对我有用的解决方案是添加缺少的开头&lt; html&gt;标记:
&lt; html xmlns =“http://www.w3.org/1999/xhtml”&gt;
或者,删除不匹配的尾随&lt; / html&gt;标记,并添加 xmlns =“http://www.w3.org/1999/xhtml”到开头&lt; ui:composition&gt;标签