使用sitemesh建立复合视图 - 1.hello
来源:互联网 发布:人工智能定理证明 编辑:程序博客网 时间:2024/05/16 06:33
http://docs.huihoo.com/java/sitemesh/
(作者: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
- www.jboss.org
- www.theserverside.com
- www.opensymphony.com
- www.atlassian.com
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.jarWEB-INF/libsitemesh-decorator.tldWEB-INFsitemesh-page.tldWEB-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建立复合视图 - 1.hello
- 使用sitemesh建立复合视图
- 使用sitemesh建立复合视图
- sitemesh 建立复合视图
- sitemesh建立复合视图(1)
- sitemesh建立复合视图(2)
- sitemesh decorators 复合页面Demo
- 使用SiteMesh
- sitemesh 使用
- sitemesh使用
- 建立复合主键
- hibernate建立复合索引
- struts2之整合sitemesh(使用sitemesh插件)
- 整合SiteMesh 之 20.2 单独使用SiteMesh
- 直接使用代码建立Android视图元件
- 直接使用代码建立Android视图元件
- 使用Sitemesh框架
- sitemesh的使用
- 项目中那些事|ListView中嵌套ListView问题
- IN OUT NOCOPY 分析
- 程序的内存分配问题
- C++ 增强型方法
- Windows Server时间服务器配置方法
- 使用sitemesh建立复合视图 - 1.hello
- x264_macroblock_analyse模块分析-2
- 用NMAKE创建VS2012 C++工程二 创建目录结构
- BT 协议调用流程
- tips for using maven and testng/junit
- jquery dialog
- Debug和Release区别
- 如何快速接手一个项目(内部项目或开源项目)
- java发起http请求提交表单