应该把属性文件放在web-inf/classes下面
然后你读取文件的时候用InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);

解决方案 »

  1.   

    Tomcat中的属性文件都要放在web-inf/classes下
      

  2.   

    你把它放在 tomcat/bin下就能找到!
      

  3.   

    我以前也是在 classes找 a.xml文件,也是找不到,放在bin下才能找到,
    环境变量都设好了,都会出现这样的问题(tomcat 4.x)的
      

  4.   

    aaa.class.getProtectionDomain().getCodeSource().getLocation()
    具体指向哪里你自己试试看吧
      

  5.   

    struts是的struts-config.xml是放在classes的外面的,怎么作的呢?
      

  6.   

    我知道怎么找到,代码如下(通过调试的):
    String rootPath = getServletContext().getRealPath("/");
    File file = new File(rootPath+"\\WEB-INF\\classes\\a.properties");
    InputStream ins = new FileInputStream(file);
    byte[] b = new byte[1024];
    while ((ins.read(b))!=-1) {
      out.print(new String(b));
    }
    其中rootPath就是webModule的根目录。
      

  7.   

    放在web-inf/classes直接用文件名就可以访问了
      

  8.   

    sandyen(杉叶)  都告诉大家了么!!

    1 应该把属性文件放在web-inf/classes下面
    2  然后你读取文件的时候用InputStream is = getClass().getClassLoader().getResourceAsStream(fileName);