1.InputStream is =[className].class.getClassLoader().getResourceAsStream("xxx.properties")
2.InputStream is =[className].class.getResourceAsStream("xxx.properties")(此方法要求properties文件与类文件在同一个目录下)
3.InputStream is=context.getResourceAsStream("/WEB-INF/classes/xxx.properties")
完整流程(记得添加try-catch):
Properties prop = new Properties();
InputStream is = [thisClassName].class.getClassLoader().getResourceAsStream("xxx.properties");
prop.load(is);
prop.close();