作者:chen-neu ,提供给
huihoo.com 发布)
使用sitemesh建立复合视图 - 1.hello <- now
使用sitemesh建立复合视图 - 2.装饰器
使用sitemesh建立复合视图 - 3.其它讨论
sitemesh是opensymphony团队开发的j2ee应用框架之一,旨在提高页面的可维护性和复用性。opensymphony的另一个广为人知的框架为webwork是用作web层的表示框架。他们都是开源的,可以在www.sf.net下找到。
应用于以下大项目的例子:http://opensource.thoughtworks.com/projects/sitemesh.html
简介: |
sitemesh应用Decorator模式,用filter截取request和response,把页面组件head,content,banner结合为一个完整的视图。通常我们都是用include标签在每个jsp页面中来不断的包含各种header, stylesheet, scripts and footer,现在,在sitemesh的帮助下,我们可以开心的删掉他们了。如下图,你想轻松的达到复合视图模式,那末看完本文吧。  |
hello sitemesh: |
- 在WEB-INF/web.xml中copy以下filter的定义:
<filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class></filter><filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern></filter-mapping><taglib> <taglib-uri>sitemesh-decorator</taglib-uri> <taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location></taglib><taglib> <taglib-uri>sitemesh-page</taglib-uri> <taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location></taglib> |
- copy所需jar和dtd文件至相应目录,访问opensymphony.sourceforge.net的cvs以获取sitemesh最新版本。
sitemesh.jar | WEB-INF/lib | sitemesh-decorator.tld | WEB-INF | sitemesh-page.tld | WEB-INF |
- 建立WEB-INF/decorators.xml描述各装饰器页面(可仿照sitemesh例子)。
<decorators defaultdir="/_decorators"> <decorator name="main" page="main.jsp"> <pattern>*</pattern> </decorator></decorators> |
- 建立装饰器页面 /_decorators/main.jsp
<%@ page contentType="text/html; charset=GBK"%><%@ taglib uri="sitemesh-decorator" prefix="decorator" %><html> <head> <title><decorator:title default="装饰器页面..." /></title> <decorator:head /> </head> <body> sitemesh的例子<hr> <decorator:body /> <hr>chen56@msn.com </body></html> |
- 建立一个的被装饰页面 /index.jsp(内容页面)
<%@ page contentType="text/html; charset=GBK"%><html> <head> <title>Agent Test</title> </head> <body> <p>本页只有一句,就是本句.</p> </body></html> | 最后访问index.jsp,将生成如下页面: 而且,所有的页面也会如同index.jsp一样,被sitemesh的filter使用装饰模式修改成如上图般模样,却不用再使用include标签。 |
分享到:
相关推荐
sitemesh-3.0-alpha-2.jar
struts2-sitemesh-plugin-2.1.8.1.jar
struts2-sitemesh-plugin-2.0.8.jar
sitemesh-2.4.2-src.jar 是sitemesh的源文件jar包,当调试时需要选择该jar包进行资源查找,很好用的页面架构工具
**sitemesh-2.2.1.jar** 是一个用于Web应用程序界面布局的开源框架,由OpenSymphony团队开发。Sitemesh的主要功能是提供页面装饰能力,它可以帮助开发者统一网站的外观和感觉,实现页面模板和内容的分离。通过在...
1. 将`struts2-sitemesh-plugin-2.2.1.1.jar`添加到项目的类路径中。 2. 在`struts.xml`配置文件中启用插件: ```xml <constant name="struts.plugin.packages" value="org.apache.struts2.sitemesh"/> ``` 3. ...
sitemesh-2.2.1.jarsitemesh-2.2.1.jarsitemesh-2.2.1.jar
sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar sitemesh-2.4.1.jar
用于在SSH2工程中使用sitemesh-2.4.jar 包;
包含struts2-core-2.5.10.1.jar,struts2-jfreechart-...struts2-sitemesh-plugin-2.5.10.1.jar,struts2-spring-plugin-2.5.10.1.jar,struts2-testng-plugin-2.5.10.1.jarstruts2-tiles-plugin-2.5.10.1.jar等jar包
struts2-sitemesh-plugin-2.0.14.jar struts2-spring-plugin-2.3.20.jar trove4j-2.0.2.jar ueditor-1.1.1.jar unoil-3.0.1.jar userSystem-1.0.jar velocity-1.5.jar xmemcached-2.0.0.jar xmemcached-...
struts2-sitemesh-plugin-2.1.6.jar
sitemesh-2.4.2.jar slf4j-api-1.7.7.jar slf4j-log4j12-1.7.7.jar spring-aop-4.1.9.RELEASE.jar spring-beans-4.1.9.RELEASE.jar spring-context-4.1.9.RELEASE.jar spring-context-support-4.1.9.RELEASE.jar ...
SiteMesh (http://www.opensymphony.com/sitemesh/). XWork (http://www.opensymphony.com/xwork/). XPP3 (http://www.extreme.indiana.edu/xgws/xsoap/xpp/). XStream (http://xstream.codehaus.org/).
SiteMesh is a web-page layout and decoration framework and web- application integration framework to aid in creating sites consisting of many pages for which a consistent look/feel, navigation and ...
struts框架与sitemesh框架整合的插件,在java web开发中可以制作模板页,使自己做的网站看起来更专业
sitemesh-2.3.jar
sitemesh-2.4.2.jar //2* spring-beansjar //1 spring-context.jar //1 spring-core.jar //1 spring-dao.jar //3 spring-hibernate3.jar //3 spring-jdbc.jar //3 spring-web-2.5.6.jar //1 struts2-core-2.1.6.jar ...
struts2-sitemesh-plugin-2.5.2.jar, struts2-spring-plugin-2.5.2.jar, struts2-testng-plugin-2.5.2.jar, struts2-tiles-plugin-2.5.2.jar, tiles-api-3.0.5.jar, tiles-autotag-core-runtime-1.1.0.jar, tiles-...
struts2-config-browser-plugin-2.3.24.jar, ...struts2-sitemesh-plugin-2.3.24.jar, struts2-spring-plugin-2.3.24.jar, struts2-struts1-plugin-2.3.24.jar, struts2-tiles-plugin-2.3.24.jar,