日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用sitemesh建立复合视图 - 1.hello

發布時間:2024/4/17 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用sitemesh建立复合视图 - 1.hello 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

簡介:
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.jarWEB-INF/lib
    sitemesh-decorator.tldWEB-INF
    sitemesh-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標簽。

    與50位技術專家面對面20年技術見證,附贈技術全景圖

    總結

    以上是生活随笔為你收集整理的使用sitemesh建立复合视图 - 1.hello的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。