您好,欢迎来到纷纭教育。
搜索
您的当前位置:首页servlet中获得tomcat项目根目录的绝对路径

servlet中获得tomcat项目根目录的绝对路径

来源:纷纭教育

 

public class CreateXmlAction extends HttpServlet {

private ServletConfig config;
    public void init(ServletConfig config) throws ServletException {
        this.config = config;
    }

public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  String  filePath = config.getServletContext().getRealPath("/");
 }

}

 

或者直接在继承了HttpServlet的Servlet中写:

Java代码 String  filePath=this.getServletConfig().getServletContext().getRealPath("/"); 

转载于:https://www.cnblogs.com/tianguook/p/3187276.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- fenyunshixun.cn 版权所有 湘ICP备2023022495号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务