Is it possible to decorate more than once in Sitemesh?

醉酒当歌 提交于 2019-12-18 15:35:31

问题


I'm trying to do something like this:

For all the requests to /admin/* I need the page to be decorated using the B decorator but also that B decorator has to be included in the content of A decorator which is main application layout.

How can I do that with Sitemesh?

Is it even possible? Or do I have to repeat the same layout from A in the B decorator?

Thanks in advance


回答1:


To answer my own question. Yes it is possible:

Using my own example, this is decorator b being decorated by decorator 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:


Here's the example using 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>


来源:https://stackoverflow.com/questions/5329693/is-it-possible-to-decorate-more-than-once-in-sitemesh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!