如何使用“javascript”访问属性文件 [英] How to access a property file using "javascript"

查看:50
本文介绍了如何使用“javascript”访问属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用javascript访问属性文件。通常属性文件是基于xml的文件。
我在Java中访问如下属性文件:

How do I access a property file using javascript. Normally property file is a xml based file. I java we access a property file like this:

Properties prop = new Properties();
            fis = getClass().getResourceAsStream("props.xml");

            if (fis != null) {
                prop.loadFromXML(fis);
            }
String dbUrl = prop.getProperty("dburl");

我想做同样的但是使用javascript。是否有可能这样做?。

I want to do the same but using javascript. is there a possible way of doing it?.

推荐答案

您无法使用javascript从用户计算机加载任何文件浏览器。

You can't load any files from the users computer with javascript in the browser.

如果文件来自您自己的服务器,您可以像使用XMLHttpRequest一样加载它。

If the file is from your own server you can load it, like any other ajax, with XMLHttpRequest.

这篇关于如何使用“javascript”访问属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆