读取web工程中.properties资源文件的模板代码

	// 读取web工程中.properties资源文件的模板代码
private void test2() throws IOException {
InputStream in = this.getServletContext().getResourceAsStream("WEB-INF/classes/db.properties");
Properties prop = new Properties();
prop.load(in); String driver = prop.getProperty("driver");
String url = prop.getProperty("url");
String username = prop.getProperty("username");
String password = prop.getProperty("password"); System.out.println(driver + " " + url + " " + username + " " + password);
}
04-26 07:26