sitemesh3.0 自定义标签
2015-12-22 10:54
316 查看
对于sitemesh3,官方只给出了<title><head><body> 三个标签,但是对于一些特殊的需求是远远不能满足的,好了,不废话了,进入正题:
本文章是基于java类来配置的,先建好sitemesh的配置类SiteMeshFilter ,如下:
“myfooter” 是我自定义的标签名字,如果需要多个,则只需要在install里面多添加一条addRule;
下面是母页面的引用:
下面是子页面的引用:
如有疑问,可留言,亦可提建议。
本文章是基于java类来配置的,先建好sitemesh的配置类SiteMeshFilter ,如下:
public class SiteMeshFilter extends ConfigurableSiteMeshFilter { @Override protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) { //customer decorator builder.addTagRuleBundle(new CustomTagRuleBundle()); } }接下来是CustomTagRuleBundle,如下:
public class CustomTagRuleBundle implements TagRuleBundle { @Override public void install(State defaultState, ContentProperty contentProperty, SiteMeshContext siteMeshContext) { defaultState.addRule("myfooter", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("myfooter"), false)); } @Override public void cleanUp(State defaultState, ContentProperty contentProperty, SiteMeshContext siteMeshContext) { } }到此为止,就可以了接下里就是解释,
“myfooter” 是我自定义的标签名字,如果需要多个,则只需要在install里面多添加一条addRule;
下面是母页面的引用:
<body> <sitemesh:write property='body'/> <div class="footer"> <p align="center">© 2016 仙飞 版权所有 </p> </div> <sitemesh:write property='myfooter'/> </body>只贴了body部分,其他的也不重要;
下面是子页面的引用:
<body> <myfooter> 自定义页脚 </myfooter> </body>
如有疑问,可留言,亦可提建议。
相关文章推荐
- 【c/c++】内存地址
- 六款 c http 服务器
- Android源码编译整理总结
- 数据结构随笔
- iOS7上的地图定位接口BUG
- C#委托的介绍(delegate、Action、Func、predicate)
- oracle 命令创建表空间以及用户、授权
- 浅析VO、DTO、DO、PO的概念、区别和用处
- php删除数组中重复元素的方法
- iOS 蓝牙
- Linux makefile 教程 非常详细,且易懂
- MySQL 报错 : too many connections
- 静态嵌套类(Static Nested Class)和内部类(Inner Class)的不同
- Centos修炼----->Centos7办公环境打造(No4 一音频和视频文件如何播放)
- iOS 开发:绘制像素到屏幕
- Ios高级绘图之路径剪切和蒙版
- js中国标准时间转换成datetime格式
- xml中处理特殊字符和转义字符
- Maven笔记(一)
- UIControl 纠错