无法将 HTML 添加到

发布于 2024-12-09 13:06:47 字数 1210 浏览 0 评论 0原文

我最近开始使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2024-12-16 13:06:47

您的 声明使用了错误的全局 XML 命名空间。您将 http://java.sun.com/jsf/facelets 定义为全局 XML 命名空间,而它本应分配给 ui: XML 命名空间。 Facelets 标记库中不存在

标记(这就是异常试图告诉您的内容)。您应该将 http://www.w3.org/1999/xhtml 指定为全局 XML 命名空间。此外, 无论如何都将被忽略。文件的唯一内容应如下所示:

<ui:composition template="/templates/masterLayout.xhtml" 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="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>

同一文件中之前或之后的任何内容都是不必要的。

另请参阅:

Your <ui:composition> declaration is using the wrong global XML namespace. You definied http://java.sun.com/jsf/facelets as global XML namespace while it should have been assigned to ui: 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 assigned http://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:

<ui:composition template="/templates/masterLayout.xhtml" 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="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>

Nothing before or after <ui:composition> in the very same file is necessary.

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文