java类中获取WEB-INF路径

 1 WEB-INF路径
 2 String path = WsTestBOImpl.class.getClass().getResource("/").getPath();
 3 path = path.substring(1, path.indexOf("classes"));
 4 
 5 web-inf 下面的classses路径(也就是src路径)
 6 String path = WsTestBOImpl.class.getClass().getResource("/").getPath();
 7 path = path.substring(1, path.length());
 8 
 9 --获取.properties配置文件的值--
10 Properties p = new Properties();
11 p.load(new FileInputStream(path + "aaa.properties"));
12 String s = p.getProperty("name");

 http://blog.csdn.net/fancylovejava/article/details/7577294

posted on 2015-10-18 12:34  ..小树苗  阅读(2453)  评论(0编辑  收藏  举报

导航