sitemesh是表现层的技术,它将公用的部分抽出来了,就不用再页面中加入大量的<include>标签了
1.
在/WEB-INF/lib中加入sitemesh的jar包,这里使用sitemesh-2.4.1.jar
2.在web.xml中加入sitemesh的过虑器:
<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"?>
<decorators defaultdir="/decorators">
<decorator name="main" page="default.jsp">
<pattern>*</pattern>
</decorator>
</decorators>
4.在webroot下加入decorator文件夹,并加入一个文件default.jsp,内容为:
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<html>
<head>
<title>
<!--把请求的原始页面的body内的全部内容插入到相应位置-->
<!-- 如果页面中没有title就用default设置的 -->
<decorator:title default="test sitemesh" />
</title>
<decorator:head />
</head>
<body>
<center>
<font color="red" size="7">top</font><!-- 头部 -->
<hr>
<decorator:body /> <!-- 把请求的原始页面的body内的全部内容插入到相应位置 -->
<hr>
<font color="red" size="7">bottom</font><!-- 尾部 -->
</center>
</body>
</html>
这样就已经完成了一个最简单的实例了,访问项目中的任何一个页面就可以看到效果了 ^_^
工程下载
分享到:
相关推荐
struts2+sitemesh例子 该例子描述了struts2+sitemesh的配置,比较实用
sitemesh 例子,里面举例一个简单例子,而且还有一个简单文档说明
初学sitemesh做了个简单的例子,希望对初学的人有用吧
这个是sitemesh在项目中的应用,还有相关的jar包和资料,最重要的还有例子。
sitemesh 使用例子。 <?xml version="1.0" encoding="utf-8"?> <decorators defaultdir="/decorators"> <!-- 此处用来定义不需要过滤的页面 --> <excludes> </excludes> <!-- 用来定义装饰器要过滤的...
freemarker 与sitemesh 整合!是一个不错的例子
SpringMVC-Freemarker_Sitemesh3例子, maven构建。
SiteMesh简介: SiteMesh是一个Web页面布局修饰框架, 用于构建包含大量页面, 需要一致的外观样式(look/fell), 导航和布局机制的大型网站. SiteMesh应用Decorator模式,用filter截取request和response,把页面组件...
很简单的sitemesh入门教程,希望对大家有所帮助
入门的demo...siteMesh与freemarker结合。。 siteMesh与velocity结合。。并且在siteMesh.xml用了不同的装饰器。。每个装饰器都有注释。。可以帮助理解。。请看readme.txt
springmvc + mybatis + sitemesh3 超简洁例子 整合springmvc mybatis 方法请看: http://blog.csdn.net/kokoyuo/article/details/52808510
springmvc + mybatis + sitemesh3登陆 超简洁例子mysql 增加了MD5验证
Struts2.0 与 sitemesh的例子 博文链接:https://jiangyou001.iteye.com/blog/183698
web布局框架 SiteMesh教程及SiteMesh官方文档翻译
sitemesh 装饰 母版
siteMesh demo siteMesh使用文档
jQuery+json+struts2+spring3(事务,AOP,IoC即DI)+hibernte3+EhCache+oscache+proxool+MySQL+SiteMesh+Gzip lj例子