String realPath = config.getServletContext().getRealPath("12345.txt");

解决方案 »

  1.   

    File file=new File(".");
    自己解析结果就可以了。
      

  2.   

    但是我这么写返回的还是
    C:\Documents and Settings\Administrator\「开始」菜单\程序\Jakarta Tomcat 4.0
      

  3.   

    class test{
    public static void main(String[] args){
    String path = test.class.getProtectionDomain().getCodeSource().getLocation().getFile();
    System.out.println(path);
    }
    }
      

  4.   

    又或者
    test.class.getResource("").getFile();---------------
    [email protected]