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

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

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

    數據加載中……
    sitemesh 簡單入門 之三
    2008年4月16日 20:45:55 Edited by DingDangXiaoMa
    sitemesh 與velocity ,freemarker 結合。(參考資料 sitemesh-example.war)
    準備:commmons-collections.jar, freemarker.jar sitemesh-2.3.jar velocity-dep-1.3.1.jar velocity-tools-view-1.1.jar
    (1)sitemesh 與velocity
    web.xml
        <servlet>
            
    <servlet-name>sitemesh-velocity</servlet-name>
            
    <servlet-class>
                com.opensymphony.module.sitemesh.velocity.VelocityDecoratorServlet
            
    </servlet-class>
            
    <load-on-startup>10</load-on-startup>
        
    </servlet>
        
    <servlet-mapping>
            
    <servlet-name>sitemesh-velocity</servlet-name>
            
    <url-pattern>*.vm</url-pattern>
        
    </servlet-mapping>
    decorators/velocity.vm
    <html>
        
    <head>
            
    <title>Velocity Decorator - $title</title>
            
    <link href="$base/decorators/main.css" rel="stylesheet" type="text/css">
            $head
        
    </head>
        
    <body>
          
    <div id="pageTitle">$title</div>
          
    <hr/>
          $body
          
    <div id="footer">
              
    <b>Disclaimer:</b> This site is an example site to demonstrate SiteMesh. It serves no other purpose.
          
    </div>
        
    </body>
    </html>
    與一次的代碼是差不太多,只不過用$標記來代替以前的<decorator:title /> <decorator:body />
    編寫 WebRoot/velocity.html
    <html>
        
    <head>
            
    <title>Velocity Test</title>
        
    </head>
        
    <body>
            
    <p>This page is decorated by the VelocityDecoratorServlet.</p>
            
    <p>Go <a href="index.html">back</a>.</p>
        
    </body>
    </html>
    把velocity.html映射到velocity.vm上。
    WEB-INF/decorators.xml添加如下映射.
    <decorator name="velocity" page="velocity.vm">
            
    <pattern>/velocity.html</pattern>
    </decorator>
    再運行程序:http://localhost/sitemesh/velocity.html就可看到映射后的樣式了, sitemesh與velocity結合。
    (2) sitemesh 與freemarker
    與上例同步。
    web.xml 加入如下servlet 映射:
        <servlet>
            
    <servlet-name>sitemesh-freemarker</servlet-name>
            
    <servlet-class>
                com.opensymphony.module.sitemesh.freemarker.FreemarkerDecoratorServlet
            
    </servlet-class>
            
    <init-param>
                
    <param-name>TemplatePath</param-name>
                
    <param-value>/</param-value>
            
    </init-param>
            
    <init-param>
                
    <param-name>default_encoding</param-name>
                
    <param-value>UTF-8</param-value>
            
    </init-param>
            
    <load-on-startup>1</load-on-startup>
        
    </servlet>
        
    <servlet-mapping>
            
    <servlet-name>sitemesh-freemarker</servlet-name>
            
    <url-pattern>*.ftl</url-pattern>
        
    </servlet-mapping>
    添加:decorators/freemarker.ftl
    <html>
        
    <head>
            
    <title>Freemarker Decorator - ${title}</title>
            
    <link href="${base}/decorators/main.css" rel="stylesheet" type="text/css">
            ${head}
        
    </head>
        
    <body>
          
    <div id="pageTitle">${title}</div>
          
    <hr/>
          ${body}
          
    <div id="footer">
     
    <b>Disclaimer:</b> This site is an example site to demonstrate SiteMesh. It serves no other purpose.
          
    </div>
        
    </body>
    </html>
    添加:webRoot/freemarker.html
    <html>
        
    <head>
            
    <title>Freemarker Test</title>
        
    </head>
        
    <body>
            
    <p>This page is decorated by the FreemarkerDecoratorServlet.</p>
            
    <p>Go <a href="index.html">back</a>.</p>
        
    </body>
    </html>
    添加兩者之間的映射:WEB-INF/decorators.xml
    <decorator name="freemarker" page="freemarker.ftl">
            
    <pattern>/freemarker.html</pattern>
     
    </decorator>
    運行http://localhost/sitemesh/freemarker.html .即可看到結果。
    今天就到這里,先這樣吧。

    posted on 2008-04-16 21:16 叮當小馬 閱讀(658) 評論(0)  編輯  收藏 所屬分類: OpenSymphony


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


    網站導航:
     
    主站蜘蛛池模板: 久久久久女教师免费一区| 免费看污成人午夜网站| 亚洲午夜未满十八勿入| 久久久久久曰本AV免费免费| 色噜噜的亚洲男人的天堂| 国产AV无码专区亚洲AV男同| 成人免费一区二区无码视频| 黄色a三级免费看| 亚洲综合男人的天堂色婷婷| 免费在线一级毛片| 永久免费在线观看视频| 特级aa**毛片免费观看| 亚洲第一成年网站大全亚洲| 夜色阁亚洲一区二区三区| 久久免费区一区二区三波多野| 亚洲av无码专区在线观看下载| 亚洲AV中文无码字幕色三| 国产18禁黄网站免费观看| 免费一级不卡毛片| 鲁啊鲁在线视频免费播放| 亚洲六月丁香六月婷婷色伊人 | 最近2019中文字幕mv免费看| 香蕉免费在线视频| 亚洲AV无码之国产精品| 亚洲国产精品成人综合色在线婷婷| 免费一级毛片不卡不收费| 国产1024精品视频专区免费| 99久久99这里只有免费的精品| 亚洲youwu永久无码精品 | 久久精品国产亚洲AV麻豆~| 国产成人3p视频免费观看 | 狠狠亚洲狠狠欧洲2019| 性色av免费观看| 蜜桃AV无码免费看永久| 日韩精品无码免费专区午夜不卡| 国产精品无码亚洲一区二区三区| 亚洲黄色在线网站| 久久精品国产亚洲香蕉| 久久亚洲精品无码播放| 亚洲国产a级视频| 国产乱弄免费视频|