`
小鑫。
  • 浏览: 133604 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

sitemesh

 
阅读更多
sitemesh
OS(OpenSymphony)的SiteMesh是一个用来在JSP中实现页面布局和装饰(layout and decoration)的框架组件,能够帮助网站开发人员较容易实现页面中动态内容和静态装饰外观的分离。



1.引入jar包
https://github.com/sitemesh/sitemesh3/downloads
2.配置web.xml
<web-app>

  <filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

</web-app>

3.创建装饰模板,包含内容的占位符<title>,<head>,<body>
<html>
  <head>
    <title>SiteMesh example: <sitemesh:write property='title'/></title>
    <style type='text/css'>
      /* Some CSS */
      body { font-family: arial, sans-serif; background-color: #ffffcc; }
      h1, h2, h3, h4 { text-align: center; background-color: #ccffcc; border-top: 1px solid #66ff66; }
      .mainBody { padding: 10px; border: 1px solid #555555; }
      .disclaimer { text-align: center; border-top: 1px solid #cccccc; margin-top: 40px; color: #666666; font-size: smaller; }
    </style>
    <sitemesh:write property='head'/>
  </head>
  <body>

    <h1 class='title'>SiteMesh example site: <sitemesh:write property='title'/></h1>

    <div class='mainBody'>
      <sitemesh:write property='body'/>
    </div>

    <div class='disclaimer'>Site disclaimer. This is an example.</div>

  </body>
</html>

4.配置映射sitemesh3.xml
<sitemesh>
  <!-- 哪些路径应用哪个装饰器,可以用*进行通配 -->
  <mapping path="/*" decorator="/decorator.html"/>
  <!-- 排除那些路径 -->
  <mapping path="/brochures/*" exclue="true"/>
</sitemesh>

5.创建一个页面
<html>
  <head>
    <title>Hello World</title>
    <meta name='description' content='A simple page'>
  </head>
  <body>
    <p>Hello <strong>world</strong>!</p>
  </body>
</html>

6.结果
<html>
  <head>
    <title>SiteMesh example: Hello World</title>
    <style type='text/css'>
      /* Some CSS */
      body { font-family: arial, sans-serif; background-color: #ffffcc; }
      h1, h2, h3, h4 { text-align: center; background-color: #ccffcc; border-top: 1px solid #66ff66; }
      .mainBody { padding: 10px; border: 1px solid #555555; }
      .disclaimer { text-align: center; border-top: 1px solid #cccccc; margin-top: 40px; color: #666666; font-size: smaller; }
    </style>
    <meta name='description' content='A simple page'>
  </head>
  <body>

    <h1 class='title'>SiteMesh example site: Hello World</h1>

    <div class='mainBody'>
      <p>Hello <strong>world</strong>!</p>
    </div>

    <div class='disclaimer'>Site disclaimer. This is an example.</div>

  </body>
</html>
分享到:
评论

相关推荐

    sitemesh-3.0.1-javadoc

    SiteMesh是一个网页布局和装饰框架以及Web应用程序集成框架,可帮助创建由页面组成的网站,这些页面需要一致的外观,导航和布局方案。 SiteMesh会拦截对通过Web服务器请求的任何静态或动态生成的HTML页面的请求,...

    Struts2整合SiteMesh技巧

    Struts 2.0提供一个Sitemesh插件,允许在Sitemesh模板中使用Struts标记。 要使用Sitemesh需要包含Freemark,Sitemesh和Sitemesh插件库文件。 配置过滤器 如果需要使用Freemark模板文件作为装饰器文件,需要在web....

    MiddleGen+Sitemesh.zip

    MiddleGen-Hibernate: 本书使用版本:2.1 ... modtime=1096973436&big_mirror=0 下载文件:middlegen-2.1.zip MiddleGenIDE插件: 本书使用版本:1.2.0 ...(7)Sitemesh: ...下载文件:sitemesh-2.3.zip

    sitemesh 完美合集 4个资料和jar文件

    Sitemesh简介: SiteMesh是一个Web页面布局修饰框架, 用于构建包含大量页面, 需要一致的外观样式(look/fell), 导航和布局机制的大型网站. sitemesh应用Decorator模式,用filter截取request和response,把页面组件...

    页面装饰器(sitemesh)实例源代码

    用sitemesh页面装饰器,将大名鼎鼎的开源即时通讯服务器openfire中运用的,布局页面抽取出来。MyEclipse中可以直接部署的代码。

    sitemesh简单教程页面装配器

    sitemesh 应用 Decorator 模式,用 filter 截取 request 和 response,把页面组件 d,content,banner 结合为一个完整的视图。通常我们都是用 include 标签在每个 jsp 页面中来 断的包含各种header , ...

    SiteMesh教程及SiteMesh官方文档翻译

    web布局框架 SiteMesh教程及SiteMesh官方文档翻译

    JSP布局框架SiteMesh.zip

    SiteMesh 是一个网页布局和修饰的框架,利用它可以将网页的内容和页面结构分离,以达到页面结构共享的目的。Sitemesh是由一个基于Web页面布局、装饰以及与现存Web应用整合的框架。它能帮助我们在由大 量页面构成的...

    siteMesh demo+文档

    siteMesh demo siteMesh使用文档

    sitemesh.jar包

    sitemesh.jar包 sitemesh.jar 包sitemesh.jar 包sitemesh.jar包

    sitemesh-2.2.1.jar sitemesh-2.2.1.jar

    sitemesh-2.2.1.jar

    sitemesh框架简单例子

    很简单的sitemesh入门教程,希望对大家有所帮助

    sitemesh-3.0.1.jar

    sitemesh 装饰页面技术.

    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 sitemesh-2.4.1.jar

    spring-boot-sitemesh源码整合

    spring-boot-sitemesh 源码整合

    springMVC与sitemesh的结合

    springMVC与sitemesh的结合,

    sitemesh3-demo

    sitemesh3-demo 配置说明参见http://blog.csdn.net/thc1987/article/details/6913416

    sitemesh框架使用 自我整理

    公司的OA流項目視圖層都是採用sitemesh技術,感覺還可以,裝潢頁面,技術不是很複雜,頁面結構清晰,佈局明朗,很好的佈局框架。

    sitemesh3官方下载包

    sitemesh3包括lib,api,demo,配置说明,希望大家喜欢

Global site tag (gtag.js) - Google Analytics