---
title: "动态获取工程中配置文件的路径"
author: "gu6866"
date: "2012-04-28T12:47:25Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2012-04-28T13:50:06Z"
id: 1503297
url: "https://premier9527.iteye.com/blog/1503297"
---

说明：获取工程中src目录下config.properties文件的路径
Java代码：
public class Config{
    public static String getConfigUrl(){
    	String classurl  = Config.class.getResource("Config.class").getPath();
      //代码编译后配置文件会放在WEB-INF/classes目录下
		     return classurl.substring(1,classurl.indexOf("WEB-INF")+"WEB-INF".length())+"/classes/config.properties"; 		
    }
}