從request獲取各種路徑總結(jié)
request.getRealPath("url");//虛擬目錄映射為實(shí)際目錄request.getRealPath("./");//網(wǎng)頁(yè)所在的目錄
request.getRealPath("../");//網(wǎng)頁(yè)所在目錄的上一層目錄
request.getContextPath();//應(yīng)用的web目錄的名稱
如http://localhost:7001/bookStore/
/bookStore/ => [contextPath] (request.getContextPath())
獲取Web項(xiàng)目的全路徑
String strDirPath = request.getSession().getServletContext().getRealPath("/");
posted on 2007-10-12 10:30 夏雪 閱讀(2753) 評(píng)論(2) 編輯 收藏