是否可以使用 SiteMesh 提取 SCRIPT 标签?
我有自定义 JSP 标记,可以生成一些 HTML 内容,以及一些由该 HTML 代码调用的 javascript 函数。在当前的实现中,SCRIPT 标记是在 HTML 代码上方创建的。
为了避免修改现有的代码库,我想使用 SiteMesh 或其他一些装饰器工具在页面的 HEAD 部分中提取这些脚本。
我知道 SiteMesh 可以从
元素中提取内容,但我想知道是否也可以使用其他标签(例如 SCRIPT)。
SiteMesh 可以做到这一点吗?或者知道有什么工具可以让我做到这一点吗?
谢谢你!
I have custom JSP tags that generate some HTML content, along with some javascript functions that get called by this HTML code. In the current implementation, the SCRIPT tags are created just above the HTML code.
To avoid modifying the existing code base, I want to pull up these scripts inside the HEAD section of the page using SiteMesh or some other decorator tool.
I know SiteMesh can extract content from <content tag="...">
elements, but I was wondering if it was possible also with other tags, such as SCRIPT.
Is this possible with SiteMesh, or know of any tools that could allow me to do that?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SiteMesh 的 HTMLPageParser 是可扩展的,因此您可以通过扩展 HTMLPageParser 和 将 SiteMesh 配置为使用您的类而不是 HTMLPageParser,如下所示:
我想您的 ScriptExtractingRule 将按照标准 SiteMesh ContentBlockExtractingRule,将内容存储在页面上下文中,以便您的装饰器可以访问这些块,就像它们是
<内容>
块。SiteMesh's HTMLPageParser is extensible, so you can add your own custom rule to extract
<script>
elements by extending HTMLPageParser and configuring SiteMesh to use your class instead of HTMLPageParser, something like this:I imagine your ScriptExtractingRule would be modeled after the standard SiteMesh ContentBlockExtractingRule, storing the content in the page context so your decorator can access the blocks as if they were
<content>
blocks.