寻找项目的配置文件

try {
			
			
			String url = this.getClass().getResource("").getPath().replaceAll(
					"%20", " ");
			String path = url.substring(0, url.indexOf("WEB-INF"))
					+ "WEB-INF/config/programVersion.properties";
			Properties config = new Properties();
			config.load(new FileInputStream(path));
			System.out.println(config.getProperty("currentVersion"));
		} catch (Exception e) {
			e.printStackTrace();
		}
配置文件放在WEB-INF下的config文件夹下,可任意更改

 

 

 

你可能感兴趣的:(Web)