如果是这样那路径不多,你可以这样,你首先用getClass().getResource("这里是你本文件的类名");
 这样取得了你所在应用的classes 目录,然后你该知道怎么做了吧,通过处理可以得到你想要的路径

解决方案 »

  1.   

    可是我的java类是放在jar包里的,而属性文件不能放在jar包里,因为该属性文件是可以修改的。
      

  2.   

    因为web-inf目录不是web项目的类路径,所以不能使用加载资源的方式读取,把这个类拷贝到web-inf\classes目录下就可以getClass().getResource("/test.properties");来读取http://www.javayou.com
      

  3.   

    将properties文件放到web-inf/classes目录下,如果没有这个目录新建一个就可以了
      

  4.   

    ./test.properties;    就OK了
      

  5.   

    Properties  property= new Properties();
         try{
           FileInputStream in = new FileInputStream(servletContext.getRealPath(
               "WEB-INF/test.properties"));
         property.load(in);
         }catch (java.io.FileNotFoundException ex){
           ex.printStackTrace();
         }catch (java.io.IOException ioe){
           ioe.printStackTrace();
         }
      

  6.   

    Properties props = new Properties();
                String fileName = "aa.properties";
                FileInputStream in = new FileInputStream(fileName);
                props.load(in);