隨筆 - 5  文章 - 4  trackbacks - 0

          留言簿

          文章分類(2)

          文章檔案(7)

          搜索

          •  

          最新評論

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

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

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

          servlet使用外部配置導(dǎo)入資源,需要在 web.xml進(jìn)行配置
          <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使用外部配置導(dǎo)入資源
          <%
          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內(nèi)容為:external-include=WEB-INF/jspf/header_tag.jsp

          jsp導(dǎo)入上下文之外的內(nèi)容
          使用 c:import JSTL核心標(biāo)記

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

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 葫芦岛市| 东丰县| 原阳县| 黑龙江省| 噶尔县| 万全县| 昌乐县| 奉贤区| 寿光市| 石城县| 陵川县| 班戈县| 安阳县| 大名县| 灌阳县| 苏尼特右旗| 巴里| 潞西市| 湖南省| 新沂市| 上思县| 措美县| 富川| 丰县| 汨罗市| 聂拉木县| 牙克石市| 宁化县| 南岸区| 平南县| 通江县| 蒲城县| 兴文县| 揭阳市| 吴旗县| 荆门市| 闸北区| 永宁县| 鹤山市| 邢台县| 大理市|