1.通过class读取
String propURL = "/com/xx/xx/dashboard.properties" ;
Properties ps = new Properties();
ps.load(PropTest.class.getResourceAsStream(propURL));
2.通过classloader读取
String propURL = "com/xx/xx/dashboard.properties" ;
Properties ps = new Properties();
ps.load(PropTest.class.getClassLoader().getResourceAsStream(propURL));
3 通过ResourceBundle
String propURL = "com/teradata/dashboard/dashboard" ;
ResourceBundle rb = ResourceBundle.getBundle(propURL);
## getBundle(baseName, Locale.getDefault(), this.getClass().getClassLoader()),
4 获取服务器的绝对路径
request.getSession().getServletContext().getRealPath("/")
String propURL = "/com/xx/xx/dashboard.properties" ;
Properties ps = new Properties();
ps.load(PropTest.class.getResourceAsStream(propURL));
2.通过classloader读取
String propURL = "com/xx/xx/dashboard.properties" ;
Properties ps = new Properties();
ps.load(PropTest.class.getClassLoader().getResourceAsStream(propURL));
3 通过ResourceBundle
String propURL = "com/teradata/dashboard/dashboard" ;
ResourceBundle rb = ResourceBundle.getBundle(propURL);
## getBundle(baseName, Locale.getDefault(), this.getClass().getClassLoader()),
4 获取服务器的绝对路径
request.getSession().getServletContext().getRealPath("/")