蝈蝈大王

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在java web项目中获取项目的src/main/resource下的文件路径

当前类名.class.getClassLoader().getResource("/").getPath();

  比如我的当前类名叫Demo

那么:

Demo.class.getClassLoader().getResource("/").getPath();

  

 

posted on 2017-08-14 16:39  蝈蝈大王  阅读(239)  评论(0)    收藏  举报