您的位置:首页 > 编程语言 > Java开发

spring properties 资源文件 方式一

2015-11-28 14:56 453 查看


使用spring的PropertiesLoaderUtils得到properties

import org.springframework.core.io.support.PropertiesLoaderUtils;
public class PropertiesUtils {

 public static String getProperty(String name) {

  String result = null;

  java.util.Properties props;

  try {

   props = PropertiesLoaderUtils.loadAllProperties("login.properties");

   result = props.getProperty(name);//根据name得到对应的value

  } catch (IOException e) {

   // TODO Auto-generated catch block

   e.printStackTrace();

  }

  return result;
 }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: