在Sitemesh中是否可以多次进行装饰?

9
我想实现以下功能: 布局 对于所有请求/admin/*,我需要使用B装饰器来装饰页面,但是B装饰器也必须包含在A装饰器的内容中,A装饰器是主应用程序布局。
如何使用Sitemesh实现这一点?
这是否可能?还是我必须在B装饰器中重复A中的相同布局?
谢谢。
2个回答

15

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

使用我的示例,这是装饰器 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>

0

以下是使用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>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接