隨筆 - 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 冬天出走的豬 閱讀(438) 評論(0)  編輯  收藏 所屬分類: jsp技術
          主站蜘蛛池模板: 西峡县| 新余市| 建宁县| 琼结县| 博野县| 荣昌县| 新沂市| 恩平市| 沧源| 桂阳县| 平塘县| 介休市| 乌兰察布市| 灵璧县| 揭阳市| 堆龙德庆县| 浏阳市| 汨罗市| 涟源市| 绩溪县| 栾城县| 靖远县| 水城县| 双牌县| 故城县| 牟定县| 宜兴市| 城口县| 丰原市| 彭山县| 石狮市| 岳阳市| 平泉县| 兰考县| 台北县| 泰安市| 仁寿县| 理塘县| 平凉市| 乌苏市| 达拉特旗|