WEB 项目中读取 WEB-INF 目录下配置文件的方法

来源:互联网 发布:趣图制作软件 编辑:程序博客网 时间:2024/04/30 01:38

配置文件路径:

WEB-INF/appconfig/


项目 default output folder 输出路径要设定为:

SMSPlatform/WebContent/WEB-INF/classes

    public String spath = "appconfig";    // 得到应用配置文件目录    public String getConfigPath() {URL url = Thread.currentThread().getContextClassLoader().getResource("");String path = url.getPath().replace("classes", spath);path = path.substring(1);System.out.println(path);return path;    }

测试环境输出:

D:/javaDev/VitualNurse/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/SMSPlatform/WEB-INF/appconfig/

0 0
原创粉丝点击