首页 > 其他 > 详细

在服务端中,读取properties资源文件中的数据

时间:2018-11-27 12:02:57      阅读:187      评论:0      收藏:0      [点我收藏+]

1、获取到资源的路径

2、读取数据

        //properties文件对象
        Properties properties = new Properties();
        //通过HttpServletRequest request 对象 获取服务上下文环境中目标文件的真实路径
        String realPath = request.getServletContext().getRealPath("/deom.properties");
        //加载目标文件的数据
        properties.load(new FileInputStream(realPath));
        //通过键,取出对应的值
        String origin1 = properties.getProperty("origin");
     //你的后续的操作.......
    

demo.properties资源文件的数据

技术分享图片

 

 通过 Debug 调试 查看通过键取出的值

技术分享图片

 

在服务端中,读取properties资源文件中的数据

原文:https://www.cnblogs.com/oukele/p/10025404.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!