如题?

解决方案 »

  1.   

    File file = new File(new URI(Thread.currentThread().getContextClassLoader().getResource("")+"config.xml"));
      

  2.   

    File只能接受绝对路径,如果要用相对路径的话,在jsp中你可以这样处理
    String path = application.getRealPath("你的相对路径");
    然后把path传给file就可以了,希望对你有帮助。
      

  3.   

    我通常是这样处理的
    File tmpFile = new File(System.getProperty("user.dir"));
      String  filename = tmpFile.getParentFile().getParent()+所在项目路径,就可以了