【问题标题】:Is it possible to decorate more than once in Sitemesh?是否可以在 Sitemesh 中进行多次装饰?
【发布时间】:2011-07-16 19:50:42
【问题描述】:

我正在尝试做这样的事情:

对于 /admin/* 的所有请求,我需要使用 B 装饰器来装饰页面,而且 B 装饰器必须包含在作为主要应用程序布局的 A 装饰器的内容中。

如何使用 Sitemesh 做到这一点?

有可能吗?还是我必须在 B 装饰器中从 A 重复相同的布局?

提前致谢

【问题讨论】:

    标签: layout sitemesh


    【解决方案1】:

    回答我自己的问题。是的,有可能:

    使用我自己的例子,这是装饰器 b 被装饰器 a 装饰。

    <page:applyDecorator name="a">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Decorator B</title>
        <decorator:head/>
    </head>
    <body id="page-home">
        This is a test.
    </body>
    </html>
    </page:applyDecorator>
    

    【讨论】:

      【解决方案2】:

      这是使用 freemarker 的示例:

      <#assign decorator = JspTaglibs["http://www.opensymphony.com/sitemesh/decorator"]/>
      <#assign page = JspTaglibs["http://www.opensymphony.com/sitemesh/page"]/>
      <@page.applyDecorator name="a">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
          <title>Decorator B</title>
          <@decorator.head/>
      </head>
      <body id="page-home">
          This is a test.
      </body>
      </html>
      </@page.applyDecorator>
      

      【讨论】:

        猜你喜欢
        • 2011-07-10
        • 2013-03-01
        • 1970-01-01
        • 2016-05-04
        • 2012-11-19
        • 2017-02-04
        • 1970-01-01
        • 2014-02-14
        • 2014-10-28
        相关资源
        最近更新 更多