得到项目的绝对路径

    技术2022-05-20  35

    今天开发项目中发现: request.getRealPath(arg0); 报警告:

    The method getRealPath(String) from the type ServletRequest is deprecated

    request.getRealPath("") 这个方法已经不推荐使用了,那代替它的是什么方法呢?

    Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.

    request.getSession().getServletContext().getRealPath() 得到站点的绝对地址   如:

    D:/apache-tomcat-6.0.29/webapps/csts_12/

    request.getContextPath()则显示:   /csts_12


    最新回复(0)