java读取资源文件(Properties)

时间:2023-03-08 21:48:58

四步:

java代码

//new一个读取配置文件
Properties properties=new Properties();
//获取文件路径
String path=request.getServletContext().getRealPath("/dom.properties");
//读取文件内容
properties.load(new FileInputStream(path));
//获取origin的value
String origin=properties.getProperty("origin");

配置文件代码

origin=http://localhost:7070, http://localhost:8080, http://localhost:9090

java读取资源文件(Properties)

java读取资源文件(Properties)