作为一款JSP-WEB视图组织布局模板,sitemesh采用的低侵入式的JSP过滤器方式载入WEB流程的,可以装饰目标jsp页,可以与常用的JSP应用框架整合,以及整合模板组件比如Freemarker,初步设置好之后再后面的应用jsp页面及java代码中都不需要再涉及,这是优点。比较常用的有2.4.2版本,目前有3.0.1版本,两个版本的配置方式有较大区别,从2升到3貌似碰到很多问题,比如乱码问题,但也并没说就非得用3.0不是吗。描述文档见“http://wiki.sitemesh.org/wiki/display/sitemesh/Home”。
相比较而言,同类的jsp布局框架tiles3,采用类似,侵入性较多,在后续java编码跳转视图上都要考虑目标jsp路径与tiles定义配置匹配,但是据说应用tiles3框架的展现加载效率要高点,而且定义比较灵活,运用方式贯穿每个页面流程。
两者比较,表格中Decorator代表sitemesh:
Aspect | Composite View | Decorator |
Reusability | The different parts of the page (template and pieces) can be reused across the whole application. | Each decorator can be reused, but the decoration itself can be applied to one page at a time. |
Ease of configuration | Each page must be defined explicitly. | The decorator can be applied even to the entire application. |
Runtime configuration | The pages can be configured and organized at runtime | Since one page is decorated at a time, this feature is not present. |
Performances | Low overhead for composition. | The page to be decorated has to be parsed. |
sitemesh2的配置方式:
1,添加所需的jar包,以及整合入其他框架的插件类jar包
sitemesh-2.4.2.jar,比如:struts2-sitemesh-plugin-2.3.xx.jar
2,在webapp的web.xml配置过滤器
<filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
3,配置WEB-INF/decorators.xml(与其他框架整合会被自动加载)
<?xml version="1.0" encoding="UTF-8"?> <decoratos defaultdir="/jsps"> <decorator name="myDecorator" page="decorator.jsp"> <pattern>/*</pattern> </decorator> <excludes> <pattern>*.html</pattern> <pattern>*.js</pattern> <pattern>*.gif</pattern> <pattern>*.jpg</pattern> <pattern>*.png</pattern> <pattern>*.css</pattern> </excludes> <decorator name="panel" page="/jsps/footer.jsp"></decorator> </decoratos>
4,建立配置装饰页(框架页,jsp)
jsp页中引入自定义标签“decorator”对应html的body/head/title,“page”标签对应其他子页面jsp页或者html
5,其他自定义...
sitemesh3的配置方式:
1,添加jar及相关框架插件jar
sitemesh-3.0.1.jar,比如:struts2-sitemesh-plugin-2.3.xx.jar
2,在webapp的web.xml配置过滤器
3,添加sitemesh3.xml至WEB-INF/,比如
<sitemesh> <mapping path="/*" decorator="/decorator.html"/> <mapping path="/admin/*" decorator="/admin-decorator.html"/> <mapping path="/index.jsp*" exclue="true" /> </sitemesh>
4,建立配置装饰页(比如decorator.html框架页,jsp或者html页)
(与2.0不同),因为装饰页可以是纯html,不引入jsp标签,仅仅是自定义html标签"sitemesh:write",插入页面的head/body/tilte:如"<sitemesh:write property='body'/>"
那么引入其他jsp/html就得靠其他方式了。
5,其他自定义
...
相关推荐
sitemesh技术的应用.doc
Sitemesh 3 的使用及配置
sitemesh3-demo 配置说明参见http://blog.csdn.net/thc1987/article/details/6913416
sitemesh3包括lib,api,demo,配置说明,希望大家喜欢
springmvc + mybatis + sitemesh3 超简洁例子 整合springmvc mybatis 方法请看: http://blog.csdn.net/kokoyuo/article/details/52808510
SpringMVC-Freemarker_Sitemesh3例子, maven构建。
springmvc + mybatis + sitemesh3登陆 超简洁例子mysql 增加了MD5验证
SiteMesh是一款网页布局和装饰器框架,也是一个网络应用程序整合框架,它可以用来维护那些很多页面,并且希望保持所有页面的布局、链接和风格一致的大型网站应用整合与维护。使用SiteMesh可以抽象出页面中的公共布局...
sitemesh入门demo。博客 Sitemesh入门和使用笔记 对应源码
sitemesh 应用 Decorator 模式,用 filter 截取 request 和 response,把页面组件 d,content,banner 结合为一个完整的视图。通常我们都是用 include 标签在每个 jsp 页面中来 断的包含各种header , ...
sitemesh 装饰 母版
SiteMesh入门学习,很好的学习总结,让你在短时间里掌握sitemesh
web布局框架 SiteMesh教程及SiteMesh官方文档翻译
SiteMesh是一个网页布局和装饰框架以及Web应用程序集成框架,可帮助创建由页面组成的网站,这些页面需要一致的外观,导航和布局方案。 SiteMesh会拦截对通过Web服务器请求的任何静态或动态生成的HTML页面的请求,...
sitemesh3的sdk包含demo,帮助文档,包等
siteMesh demo siteMesh使用文档
SiteMesh官方文档翻译(含Freemarker但不包括velocity部分)
sitemesh3的一个demo,附带配置说明
sitemesh.jar包 sitemesh.jar 包sitemesh.jar 包sitemesh.jar包
spring-boot-sitemesh 源码整合