java读取资源文件(Properties)

四步:

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

原文地址:https://www.cnblogs.com/weibanggang/p/10025382.html