posts - 93,  comments - 2,  trackbacks - 0
          源文件為:http://wenku.baidu.com/view/433b1585d4d8d15abe234e3a.html
          下面我簡單寫下這個例子:
          第一,首先配置環(huán)境:
          (1)添加jar包,如:sitemesh-2.4.1.jar放在lib下
          在web.xml添加配置
          <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>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>FORWARD</dispatcher>
           </filter-mapping>
          第二步:
          在WEB-INF下新建decorators.xml文件
          內(nèi)容如下:
          <decorators defaultdir="/decorators">
           <decorator name="main" page="main.jsp">
            <pattern>/*</pattern>
           </decorator>
          </decorators>
          第三步:
          根據(jù)decorators.xml文件里面的屬性defaultdir在webroot下創(chuàng)建一個目錄decorators,在該目錄下創(chuàng)建一個main.jsp文件
          內(nèi)容如下:
          <%@ page contentType="text/html; charset=GBK"%>
          <%@ include file="/includes/taglibs.jsp"%>
            <html>
                 <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=gbk">
                     <title><decorator:title default="裝飾器頁面..." /></title>
                     <decorator:head />
                 </head>
                <body>
                  <div id="page">
                   <div id="header">
                       <jsp:include page="/includes/header.jsp"/>
                   </div>
                   <div id="content">
                     <decorator:body />
                   </div>
                   <div id="footer">
                       <jsp:include page="/includes/footer.jsp"/>
                   </div>
               </body>
           </html>
          第四步
          <jsp:include page="/includes/header.jsp"/>為includes目錄下的一個共同使用的內(nèi)容
          <jsp:include page="/includes/footer.jsp"/>為includes目錄下的一個共同使用的內(nèi)容
          <decorator:head /> 為每個要訪問文件的內(nèi)容
          如下所示訪問index.jsp
          index.jsp內(nèi)容為:
          <%@ page contentType="text/html; charset=GBK"%>
          <%@ include file="/includes/taglibs.jsp"%>
           <html>
                <head>
                  <title>Agent Test</title>
                </head>
                <body>
                  <p>本頁只有就是本句.</p>
                </body>
           </html>

          /includes/header.jsp內(nèi)容為:

          <%@ page language="java" contentType="text/html; charset=gbk"
              pageEncoding="gbk"%>
          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html> 
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gbk">
          </head>

                <body>
                    sitemesh的例<hr>
               </body>
          </html>

          /includes/footer.jsp內(nèi)容為:
          <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
              pageEncoding="gbk"%>
          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gbk">
          <title>Insert title here</title>
          </head>
          <body>
           <hr>chen56@msn.com
          </body>
          </html>

          訪問得到內(nèi)容如下:
          sitemesh的例




          本頁只有就是本句.



          當(dāng)然這里最主要的是要記住引入/include/taglibs.jsp
          內(nèi)容如下:
          <%@ taglib uri="

          <2013年5月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          Java

          搜索

          •  

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 商河县| 日土县| 金门县| 南宫市| 通化县| 永新县| 霸州市| 延吉市| 青海省| 永修县| 遂宁市| 平罗县| 敦化市| 绩溪县| 株洲市| 宁南县| 武邑县| 当涂县| 西充县| 龙口市| 镇坪县| 思茅市| 元氏县| 吴忠市| 东安县| 浙江省| 清远市| 镇江市| 米林县| 新干县| 柳州市| 咸阳市| 浦江县| 孝感市| 辽阳市| 济源市| 利川市| 蒲江县| 千阳县| 内江市| 湘西|