tiles vs sitemesh

Struts 内置了Tiles,利用它可以很好复用页面,使用起来就像我们复用类一样。
<card title='<tiles:getAsString name="title"/>'>   
<tiles:insertAttribute name="menu" />
<tiles:insertAttribute name="body" />
<tiles:insertAttribute name="footer" />
</card>

    <definition name="basic" template="/decorators/main.jsp">  
<put-attribute name="title" value="example" />
<put-attribute name="menu" value="/decorators/menu.jsp" />
<put-attribute name="body" value="/decorators/blank.jsp" />
<put-attribute name="footer" value="/decorators/footer.jsp" />
</definition>



Sitemesh使用Decorator模式达到预期效果。这里可以将页面分为两类,decorator(修饰)和decoratored(被修饰)。这就好比有一个相框和各种不同可以用来变换的相片,当相框中放入不同的相片,就得到不同的视觉效果。
<html>  
<head>
<title>My Site - <decorator:title default="Welcome!" /></title>
<decorator:head />
</head>

<body>
<page:applyDecorator name="panel"/>
<decorator:body />
<p><small>(<a href="?printable=true">printable version</a>)</small></p>
<page:applyDecorator name="footer"/>
</body>
</html>


<decorators defaultdir="/decorators">  
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="panel" page="panel.jsp"/>
<decorator name="footer" page="footer.jsp"/>
</decorators>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值