What does servletcontext.getRealPath(“/”) mean and when should I use it

后端 未结 4 856
无人及你
无人及你 2020-11-22 01:32

In the following snippet:

ServletContext context = request.getServletContext();
String path = context.getRealPath(\"/\");

What does /

4条回答
  •  不知归路
    2020-11-22 02:03

    My Method:

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    
        try {
            String path = request.getRealPath("/WEB-INF/conf.properties");
            Properties p = new Properties();
            p.load(new FileInputStream(path));
    
            String StringConexion=p.getProperty("StringConexion");
            String User=p.getProperty("User");
            String Password=p.getProperty("Password");
        }
        catch(Exception e){
            String msg = "Excepcion " + e;
        }
    }
    

提交回复
热议问题