<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    [轉]使用sitemesh建立復合視圖1.hello

    轉自:http://docs.huihoo.com/java/sitemesh/index.html

    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 例子:
    步驟1:在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>

    2.copy所需jar和dtd文件至相應目錄,訪問opensymphony.sourceforge.net的cvs以獲取sitemesh最新版本。
    sitemesh.jar WEB-INF/lib
    sitemesh-decorator.tld WEB-INF
    sitemesh-page.tld WEB-INF

    3.建立WEB-INF/decorators.xml 描述定義幾個裝飾器頁面 (可仿照sitemesh例子)。
    <decorators defaultdir="/decorators">
        <decorator name="main" page="main.jsp">
            <pattern>*</pattern>
        </decorator>
    </decorators>
    這里只定義了一個 main 裝飾器。

    4.建立裝飾器頁面/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>
    5.建立一個的被裝飾的頁面 /index.jsp(內容頁面)
    <%@ page contentType="text/html; charset=GBK"%>
    <html>
      <head>
        <title>Agent Test</title>
      </head>
      <body>
        <p>本頁只有一句,就是本句.</p>
      </body>
    </html>
    最后訪問index.jsp,將生成頁面。
    ------------------------------------------------------------------------------------------
    簡單地改了改sitemesh自帶的例子sitemesh-example

    /Files/hijackwust/sitemeshHelloWorld.rar

    posted on 2007-09-17 20:41 hijackwust 閱讀(303) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2007年9月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    30123456

    導航

    統計

    常用鏈接

    留言簿(6)

    隨筆檔案(57)

    友情鏈接

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 中文字幕亚洲码在线| 久久水蜜桃亚洲av无码精品麻豆| 亚洲中文字幕乱码熟女在线| 亚洲最大免费视频网| 91亚洲国产成人久久精品网站| 人人玩人人添人人澡免费| 亚洲AV第一页国产精品| 久久国产高潮流白浆免费观看| 亚洲第一成年人网站| 成人午夜免费福利| 久久久久久亚洲精品无码| 亚洲国产激情一区二区三区| 一级毛片**免费看试看20分钟 | 久久精品亚洲一区二区三区浴池| a级黄色毛片免费播放视频| 亚洲大尺度无码无码专区| 一区二区免费视频| 亚洲成人福利在线观看| 成**人免费一级毛片| 色婷婷综合缴情综免费观看| 久久九九亚洲精品| 亚洲国产精品免费观看| 亚洲AV综合色区无码一二三区 | 无码精品人妻一区二区三区免费| 亚洲无码日韩精品第一页| 黄色网址在线免费| 亚洲va乱码一区二区三区| 国产精品免费视频一区| 精品国产污污免费网站入口在线| 亚洲爱情岛论坛永久| 免费一本色道久久一区| 成人国产网站v片免费观看 | 亚洲日本一区二区三区在线| 91久久精品国产免费直播| 亚洲AV无码之国产精品| 亚洲日韩欧洲乱码AV夜夜摸| 国产va免费精品观看精品| 一级一片免费视频播放| 91亚洲视频在线观看| 亚洲精品和日本精品| 国产电影午夜成年免费视频|