隨筆 - 4  文章 - 10  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          下面用三個實驗,更清淅的理解 <jsp:include page=""/> 和 <%@ include file="" %> 的區別。
          <jsp:include page=""/> 包含被 include 文件的輸出
          <%@ include file="" %> 包含被 include 文件的代碼

          a.jsp 內容:

          < jsp:include  page ="b.jsp" />

          b.jsp 內容:(空)

          _a.class a.jsp編譯成類的內容:

          _jspService() {
              
              JspWriter jspwriter 
          =  pagecontext.getOut();
              
              
          // 把b.jsp的內容輸出到_a.class的jspwriter
              JspRuntimeLibrary.include(httpservletrequest, httpservletresponse,  " b.jsp " , jspwriter,  false );
              
          }
           

          -------------------------------------------------------------------------------------
              
          a.jsp 內容:

          <% @ include file = " b.jsp "   %>  

          b.jsp 內容:

          abcd

          _a.class a.jsp編譯成類的內容

          // b.jsp中"abcd"字符串作為_a.class的成員變量
          private   static   final   char  _jsp_string1[]  =   " abcd " .toCharArray(); 
          _jspService()
          {
              
              JspWriter jspwriter 
          =  pagecontext.getOut();
              jspwriter.write(_jsp_string1);
              
          }

          -------------------------------------------------------------------------------------

          a.jsp 內容:

          <% @ include file = " b.jsp "   %>  

          b.jsp 內容:

          <% out.println( " efg " ); %>

          _a.class a.jsp編譯成類的內容

           

          _jspService() {
              
              jspwriter.println(
          " efg " );
              
          }

          以上是在用 WebSphere Application Server 6.1 編譯生成的代碼反編譯出來的 _a.class。

          接下來要看看 jsp 指令,如:
          <%@page contentType="text/html; charset=UTF-8" %>
          <%@page autoFlush="false" %>
          <%@page buffer="20kb" %>
          <%@page isThreadSafe="true" %>
          <%@page errorPage="" %>
          <%@page extends="" %>
          ....................

          會體現在生成的 class 文件的何處,分別起什么作用。

          posted on 2007-08-13 10:28 冬天出走的豬 閱讀(437) 評論(0)  編輯  收藏 所屬分類: jsp技術
          主站蜘蛛池模板: 罗城| 师宗县| 德惠市| 漳州市| 白山市| 邢台市| 岑溪市| 斗六市| 建昌县| 高台县| 万年县| 桐柏县| 桑植县| 巫溪县| 龙川县| 唐河县| 利津县| 磐石市| 万全县| 江达县| 柳州市| 嘉祥县| 宝坻区| 当雄县| 武宁县| 澜沧| 南城县| 大化| 松滋市| 景泰县| 龙山县| 苗栗市| 阜阳市| 荔浦县| 南华县| 太谷县| 武安市| 安图县| 昌图县| 凤阳县| 抚远县|