public static void main(String[] args) {
Properties properties = new Properties();
try {
InputStream inputStream = new FileInputStream("src/methodProperties.properties");
properties.load(inputStream);
System.out.println(properties.getProperty("org.svse.service.UserInfoService.update"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}这里在main中用 src/methodProperties.properties 路经没有问题
现在发在web服务器上的路经是怎么写呢

解决方案 »

  1.   

    哥们,看看这个问题。我的跟你的问题差不多
    http://topic.csdn.net/u/20100312/23/6f16794a-25e0-4178-86d1-8bb10677b573.html
    再给你补充下
    System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));
    System.out.println(Test.class.getClassLoader().getResource(""));
    System.out.println(ClassLoader.getSystemResource(""));  
    System.out.println(Test.class.getResource(""));  
    System.out.println(Test.class.getResource("/")); //Class文件所在路径  
    System.out.println(new File("/").getAbsolutePath());  
    System.out.println(System.getProperty("user.dir")); 
      

  2.   

    我是打算用spring的aop做操作日志,现在key-value都在properties文件内,发在web服务器上这路经就不知道怎么写了
      

  3.   


    同目录的话不用写那么多 如果不同目录的话建议LZ根据用getResource方法获取下绝对路径吧
      

  4.   

    谢谢大家
    Thread.currentThread().getContextClassLoader().getResource("") 这个可以拿到web目录下的路经了 
    现在读取的还是null 我得检查检查了