siteMesh 2.3(4) printable参数

可打印的装饰器,可以允许你当用http://localhost/a.html?printable=true方式访问时,应用其他的装饰器(自己指定),给出原始页面以供打印(免得把header,footer等的花哨的图片也搭上)

让我们来看一看怎样实现他:

1.首先在WEB-INFO/sitemesh.xml中设置:
     <mapper class="com.opensymphony.module.sitemesh.mapper.PrintableDecoratorMapper">
       <param name="decorator" value="printable" />
       <param name="parameter.name" value="printable" />
       <param name="parameter.value" value="true" />
     </mapper>
这样就可以通过?printable=true来使用名为printable的装饰器,而不是用原来的装饰器。

2.WEB-INFO/decorators.xml中定义相应的printable装饰器
     <decorator name="printable" page="printable.jsp"/>

3.最后编写printable装饰器/decorators/printable.jsp

<%@ taglib uri="sitemesh-decorator" prefix="decorator" %>
<html>
<head>
     <title><decorator:title /></title>
     <decorator:head />
</head>
<body>

     <h1><decorator:title /></h1>
     <p align="right"><i>(printable version)</i></p>

     <decorator:body />

</body>
</html>

这样就可以让一个原始页面通过?printable=true开关来切换不同的装饰器页面。

注:

printable:打印被装饰的页面:index.jspprintable.jsp页面中的内容。不会打印main.jsp页面中的内容,使用提供的demoprintable的运行截图为:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值