无法将 HTML 添加到
我最近开始使用 JSF2.0 和 Facelets,但我希望对你们大多数人来说这是一个简单的答案。当我尝试在
标记中添加任何 HTML 标记时,我收到以下错误:
javax.faces.view.facelets.TagException: /content/home/test.xhtml @11,10 标签库支持命名空间: http://java.sun.com/jsf/facelets,但没有为 name: div 定义标签
如果我从该部分中删除所有 HTML 标签,页面将正确显示。这是我一直在尝试使其工作的简单页面:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:jrc="http://com.comanche.web.components">
<ui:composition template="/templates/masterLayout.xhtml" xmlns="http://java.sun.com/jsf/facelets">
<ui:define name="windowTitle">Home</ui:define>
<ui:define name="content">
<div>I want to add HTML and am having lots of trouble.</div>
</ui:define>
</ui:composition>
</html>
我知道我应该能够在定义标记中添加 HTML。我需要做什么才能不出现任何错误地输入 HTML。
I have recently started working with JSF2.0 and Facelets, but have run into what I hope is an easy answer for most of you out there. When I am trying to add any HTML tag within a <ui:define>
tag I receive the following error:
javax.faces.view.facelets.TagException: /content/home/test.xhtml @11,10 Tag Library supports namespace: http://java.sun.com/jsf/facelets, but no tag was defined for name: div
If I remove all of the HTML tags from the section the page displays correctly. Here is my simple page that I have been trying to get working:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:jrc="http://com.comanche.web.components">
<ui:composition template="/templates/masterLayout.xhtml" xmlns="http://java.sun.com/jsf/facelets">
<ui:define name="windowTitle">Home</ui:define>
<ui:define name="content">
<div>I want to add HTML and am having lots of trouble.</div>
</ui:define>
</ui:composition>
</html>
I know I should be able to add HTML within the define tag. What do I need to do to get HTML in without any errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
声明使用了错误的全局 XML 命名空间。您将http://java.sun.com/jsf/facelets
定义为全局 XML 命名空间,而它本应分配给ui:
XML 命名空间。 Facelets 标记库中不存在标记(这就是异常试图告诉您的内容)。您应该将
http://www.w3.org/1999/xhtml
指定为全局 XML 命名空间。此外,和
无论如何都将被忽略。文件的唯一内容应如下所示:
同一文件中
之前或之后的任何内容都是不必要的。另请参阅:
Your
<ui:composition>
declaration is using the wrong global XML namespace. You definiedhttp://java.sun.com/jsf/facelets
as global XML namespace while it should have been assigned toui:
XML namespace. The<div>
tag doesn't exist in the Facelets taglib (which is what the exception is trying to tell you). You should have assignedhttp://www.w3.org/1999/xhtml
as global XML namespace. Further, the<!DOCTYPE>
and<html>
will be ignored anyway. The sole content of the file should be the following:Nothing before or after
<ui:composition>
in the very same file is necessary.See also: