空間站

          北極心空

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            15 Posts :: 393 Stories :: 160 Comments :: 0 Trackbacks

          在Servlet與JSP中取得當(dāng)前文件所在的相對(duì)路徑與絕對(duì)路徑

          //Servlet中

          //JSP中的application對(duì)象就是Servlet中的ServerContext,所以在Servlet中是如此獲得

          //import java.io.File;

          System.out.println("根目錄所對(duì)應(yīng)的絕對(duì)路徑:" + request.getServletPath() + "
          ");

          String strPathFile = request.getSession().getServletContext().getRealPath(request.getRequestURI());

          System.out.println("文件的絕對(duì)路徑:" + strPathFile + "
          ");

          String strDirPath = new File(request.getSession().getServletContext().getRealPath(request.getRequestURI())).getParent();

          System.out.println("目錄的絕對(duì)路徑:" + strDirPath + "
          ");

          文件名不能包括以下字符:\/:*?"<>|

          posted on 2006-11-02 10:35 蘆葦 閱讀(1119) 評(píng)論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 集安市| 买车| 沾化县| 确山县| 博野县| 屏边| 长垣县| 夏津县| 曲水县| 磐石市| 遂宁市| 蓬莱市| 谷城县| 浪卡子县| 舞钢市| 郁南县| 施秉县| 吴堡县| 昆明市| 牙克石市| 白山市| 彰化县| 萨嘎县| 岗巴县| 连城县| 娱乐| 株洲市| 屏东县| 大新县| 泰来县| 门源| 即墨市| 隆化县| 全南县| 定西市| 永清县| 涟水县| 兴国县| 百色市| 博罗县| 五家渠市|