为什么不直接放在WEB-INF\classes下面,如果直接放在WEB-INF\classes下面就很容易了。
直接用resourcebundle或者Class.getresourceasstream都能够很容易获取到。如果放在WEB-INF的config目录,我估计得先获取工程的目录,然后再根据工程目录的相对目录找到文件。

解决方案 »

  1.   

    路径不是试出来的,建议楼主先了解清楚classpath的概念。你就不会不知道文件该放在哪儿了
      

  2.   

    楼主可以在路径上面试试 “../”+你的路径,这种表示方法是往上一层,代码的运行是在classes包里面的,这样就可以跳出这个文件夹在父文件夹中选择包了,下面应该是config\~~~。
      

  3.   

    Class.getResourceAsStream(String path) 
    path 不以’/'开头时默认是从此类所在的包下取资源,以’/'开头则是从ClassPath根下获取。
      

  4.   

    直接写不行么
    WEB-INF\config\uas-system.properties
      

  5.   

    request.getSession().getServletContext().getRealPath("/WEB-INF/config/uas-system.properties");
      

  6.   

    String path = SysConfig.class.getClassLoader().getResource("").getPath();
      

  7.   

    算了,不纠结了,如果谁知道怎么把WEB-INF\config\uas-system.properties的文件读出来希望能把测试后的带发上来~
    我已经把properties文件放入classes文件夹下了,用以下代码可以:public static String readValue(String key) {
    Properties props = new Properties();
    try {
    InputStream in=UasTagFunction.class.getResourceAsStream("/uas-operation.properties");
    props.load(in);
    String value = props.getProperty(key);
    return value;
    } catch (Exception e) {
    e.printStackTrace();
    return "";
    }
    }
      

  8.   

    public static String readValue(String key) {
            Properties props = new Properties();
           FileInputStream fis=null
            try {
                fis=new FileInputStream(new File(UasTagFunction.class.getResource("/").getPath()+"config\uas-system.properties"));
                props.load(fis);
                String value = props.getProperty(key);
                return value;
            } catch (Exception e) {
                e.printStackTrace();
                return "";
            }
        }
      

  9.   

    public static String readValue(String key) {
            Properties props = new Properties();
            FileInputStream fis=null
            try {
                fis=new FileInputStream(new File(UasTagFunction.class.getResource("/").getPath()+"config/uas-system.properties"));
                props.load(fis);
                String value = props.getProperty(key);
                return value;
            } catch (Exception e) {
                e.printStackTrace();
                return "";
            }
        }