隨筆 - 5  文章 - 4  trackbacks - 0

          留言簿

          文章分類(2)

          文章檔案(7)

          搜索

          •  

          最新評論

          servlet中
          RequestDispatcher dispatcher = request.getRequestDispatcher(path);
          dispatcher.include(request,response);

          jsp中
          <%@ include file="path"  %> (目前我沒有測試出來這兩者的區別,可能是使用eclipse的原因,一旦保存了后,將自動構建)
          <jsp:include page="<%=path %>" >

          這里面的 path 如果以 /起頭,比如
          /test/hello.jsp 就代表上下文的這個文件
          ./test/hello.jsp 當前文件下的/test/hello.jsp
          ../test/hello.jsp 當前文件的父親的/test/hello.jsp
          path同樣可以是servlet里的mapping映射

          servlet使用外部配置導入資源,需要在 web.xml進行配置
          <servlet>
           <description></description>
           <display-name>HelloWorldServlet</display-name>
           <servlet-name>HelloWorldServlet</servlet-name>
           <servlet-class>testservlet.HelloWorldServlet</servlet-class>
           <init-param>
            <param-name>file</param-name>
            <param-value>/PrintLog</param-value>
           </init-param>
          </servlet>
          通過 String value = (String) getInitParameter("file"); 得到 /PrintLog

          jsp使用外部配置導入資源
          <%
          java.util.ResourceBundle bundle = new java.util.ResourceBundle.getBundle("com.jspservletcookbook.include");
          String segment = budle.getString("external-include");
          %>
          文件 include.properties 儲存在 WEB-INF/classes/com/jspservletcookbook
          文件 include.properties內容為:external-include=WEB-INF/jspf/header_tag.jsp

          jsp導入上下文之外的內容
          使用 c:import JSTL核心標記

          posted on 2006-12-08 11:52 googlor 閱讀(437) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 石台县| 巩义市| 溆浦县| 普定县| 克东县| 乌兰县| 杭锦后旗| 中方县| 虞城县| 永城市| 靖安县| 永丰县| 抚松县| 台湾省| 噶尔县| 赣州市| 定边县| 兰西县| 宁河县| 遵义县| 南康市| 房产| 德保县| 彩票| 厦门市| 连南| 徐水县| 惠安县| 东方市| 桃园县| 牡丹江市| 砀山县| 凤凰县| 武宁县| 岳阳县| 什邡市| 鲁山县| 武平县| 嘉定区| 黄龙县| 凤山县|