Sitemesh 2.4.2:如何使用除装饰器之外的装饰器

时间:2014-01-23 20:09:07

标签: jsp struts2 sitemesh

我正在使用struts2-archetype-starter maven模板来创建Struts2 webapp。虽然,之前我使用过Struts2,但我是Sitemesh的新手。我的adminTemplate.jsp文件夹中有一个decorator,其中包含一个

<decorator:body />

标签。我们知道,body并不是我们想要自定义的唯一内容,我需要在页面中使用一些自定义脚本<decorator:body />位于页脚之上(脚本不是很好)。

我还尝试引用sitemesh提供的文档,这里: -

http://wiki.sitemesh.org/display/sitemesh/Passing+Additional+Elements+to+the+Decorator

但遗憾的是,该页面根本没有任何文字。

任何人都可以告诉我如何实现同样的目标吗?如果任何人都可以留下指向一些优秀文档的指针,将会非常有帮助。

1 个答案:

答案 0 :(得分:2)

您可以在adminTemplate.jsp中插入 head 占位符

<head>
  <title>
    <decorator:title/>
  </title>
  ...
  ...
  <decorator:head/>
</head>

然后在您的网页中自定义脚本

<head>
  <title>
    page1
  </title>
  <script>
    ....
  </script>
</head>