servlet中獲取路徑

request..getServletPath();           //獲得該Servlet的訪問相對路徑   /control.action


request.getSession.getServletContext().getRealPath(request.getRequestURI());  

    //  獲得該Servlet的絕對路徑    F:\workspace\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ShopCart\ShopCart\control.action


getServletConfig().getServletContext().getRealPath("/");

     //獲得該Servlet的相對路徑    F:\workspace\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ShopCart\

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章