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

          搜索

          •  

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 泽库县| 合水县| 江西省| 安西县| 攀枝花市| 彭泽县| 广安市| 化隆| 屯留县| 周宁县| 辰溪县| 沙雅县| 华池县| 崇信县| 彝良县| 古蔺县| 郎溪县| 历史| 昌吉市| 罗定市| 宾阳县| 梨树县| 洛川县| 兖州市| 丰台区| 鲜城| 汝阳县| 电白县| 和田县| 吉林省| 萨迦县| 沛县| 江永县| 蒲城县| 旌德县| 利津县| 天等县| 中江县| 梧州市| 内乡县| 宁都县|