隨筆 - 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 閱讀(438) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 新河县| 成都市| 水富县| 鞍山市| 云龙县| 台州市| 临桂县| 萨嘎县| 峨山| 伊宁市| 普洱| 彰化市| 哈密市| 墨玉县| 清新县| 神农架林区| 秦皇岛市| 吉林省| 平山县| 夏河县| 正安县| 平和县| 永和县| 陇川县| 木兰县| 榆林市| 嘉善县| 金阳县| 饶阳县| 建瓯市| 盐亭县| 霞浦县| 桑植县| 峨山| 连城县| 宝丰县| 东平县| 都江堰市| 玉溪市| 吴川市| 宜昌市|