servlet中获取路径

来源:互联网 发布:数据库基础知识题库 编辑:程序博客网 时间:2024/06/05 15:23

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\

0 0
原创粉丝点击