weblogic和tomcat下通用的获取路径或者加载资源的方法

1、获取路径

this.getClass().getClassLoader().getResource("/").getPath();  //格式如...../WEB-INFO/class/

 

2、加载配置文件

若配置文件是在源文件根目录

InputString is = Thread.currentThread().getContextClassLoader().getResourceAsStream("xxxx.properties");

InputStream in = getClass().getResourceAsStream("/config.properties");//只能静态类用

相关文章:

  • 2022-01-07
  • 2022-01-22
  • 2022-01-31
  • 2022-12-23
  • 2021-08-14
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2021-05-26
  • 2022-01-17
  • 2021-11-18
  • 2021-09-03
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案