码迷,mamicode.com
首页 > Web开发 > 详细

WEB程序下 获取src目录下的properties

时间:2016-03-11 12:31:41      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:src   properties   

因为是WEB环境,所以在查找文件时不能像main方法一样查找,比如写src/test.properties,在运行时时找不到的


文件路径需要改写成

xxx.class.getClassLoader() .getResource("").getPath().substring(1)
                + "test.properties"

WEB程序下 获取src目录下的properties

标签:src   properties   

原文地址:http://elisazhang.blog.51cto.com/6332349/1749810

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!