如何在 Wicket 中指定 HEAD 元素的 PROFILE 属性?

发布于 2024-12-23 05:07:18 字数 650 浏览 3 评论 0原文

我正在使用 Wicket,我需要我的页面在其 head 元素中包含 profile 属性。由于 Wicket 负责渲染实际的 head 部分,因此不清楚如何执行此操作。我需要这样的 HTML:

<head profile="http://a9.com/-/spec/opensearch/1.1/">
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

对于感兴趣的读者,我正在尝试宣传我的 Web 应用程序的 OpenSearch 描述文档,如下所示: http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document

顺便说一句,当Web 框架让像这样的小任务变得如此困难!

I am using Wicket and I need my pages to include the profile attribute with their head element. Since Wicket takes care of rendering the actual head section it is not apparent how to do this. I need HTML like so:

<head profile="http://a9.com/-/spec/opensearch/1.1/">
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

For the interested reader, I am trying to advertise my web application's OpenSearch Description Document as documented here: http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document

As an aside, I find it disgruntling and bad-smelling when a trivial task like this is made so difficult by the web framework!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

半世蒼涼 2024-12-30 05:07:18

您使用什么版本的 wicket?在 Wicket 1.4 中,您可以使用 Behavior 将任何属性添加到任何标记:

HTML:

<head wicket:id="head">
    ...
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

java:

add(new WebMarkupContainer("head").add(new SimpleAttributeModifier("profile"
            ,"http://a9.com/-/spec/opensearch/1.1/")));

对于 Wicket 1.5,上述 SimpleAttributeModifier 的 Javadoc 会告诉您应该使用什么。

问候

PS:我认为这里没有什么困难。 Wicket 提供了几种添加标题部分的方法。我想向 中添加属性是一项相当不常见的任务。

What version of wicket are you using? In Wicket 1.4 you can add any attribute to any tag using an Behavior:

HTML:

<head wicket:id="head">
    ...
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

java:

add(new WebMarkupContainer("head").add(new SimpleAttributeModifier("profile"
            ,"http://a9.com/-/spec/opensearch/1.1/")));

For Wicket 1.5, the Javadoc of the above SimpleAttributeModifier tells you what to use instead.

Regards

PS: I don 't see anything difficult here. Wicket provides a few ways to contribute to the header section. I guess adding an attribute to the is a rather uncomon task.

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