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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

sitemesh应用

發布時間:2023/12/20 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sitemesh应用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考:
http://www.iteye.com/topic/251521
http://www.jb51.net/web/70208.html

依賴:

<!-- https://mvnrepository.com/artifact/opensymphony/sitemesh --><dependency><groupId>opensymphony</groupId><artifactId>sitemesh</artifactId><version>2.4</version></dependency>

使用說明:

STEP1:配置web.xml

<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>

STEP2:在[web-app]/WEB-INF/新建一個decorators.xml文件

<?xml version="1.0" encoding="utf-8"?> <decorators defaultdir="/decorators"> <!-- 此處用來定義不需要過濾的頁面 --> <excludes> </excludes> <!-- 用來定義裝飾器要過濾的頁面 --> <decorator name="main" page="main.jsp"> <pattern>/*</pattern> </decorator> </decorators>

STEP3:在[web-app]下創建一個decorators文件夾,在該文件下再創建一個裝飾頁面main.jsp,包含以下內容:

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- 第一個裝飾頁面 --> <head> <!-- 從被裝飾頁面獲取title標簽內容,并設置默認值--> <title><decorator:title default="默認title"/></title> <!-- 從被裝飾頁面獲取head標簽內容 --> <decorator:head/> </head> <body> <h2>SiteMesh裝飾header</h2> <hr /> <!-- 從被裝飾頁面獲取body標簽內容 --> <decorator:body /> <hr /> <h2>SiteMesh裝飾footer</h2> </body> </html>

STEP4:在[web-app]下創建被裝飾頁面index.jsp,包含以下內容:

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- 第一個被裝飾(目標)頁面 --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>被裝飾(目標)頁面title</title> </head> <body> <h4>被裝飾(目標)頁面body標簽內內容。</h4> <h3>使用SiteMesh的好處?</h3> <ul> <li>被裝飾(目標)頁面和裝飾頁面完全分離。</li> <li>做到真正的頁面復用,一個裝飾頁面裝飾多個被裝飾(目標)頁面。</li> <li>更容易實現統一的網站風格。</li> <li>還有。。。</li> </ul> </body> </html>

通過SiteMesh裝飾,不需要在每個目標頁面中將header和footer等共同文件include進去,被裝飾(目標)頁面和裝飾頁面完全分離。

總結

以上是生活随笔為你收集整理的sitemesh应用的全部內容,希望文章能夠幫你解決所遇到的問題。

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