我正在尝试做这样的事情:
对于 /admin/* 的所有请求,我需要使用 B 装饰器来装饰页面,而且 B 装饰器必须包含在主应用程序布局的 A 装饰器的内容中。
我如何使用 Sitemesh 做到这一点?
甚至可能吗?还是我必须在 B 装饰器中从 A 重复相同的布局?
提前致谢
回答我自己的问题。对的,这是可能的:
使用我自己的示例,这是装饰器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>
这是使用 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>