javascript 使用javascript读取属性文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15060532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 23:20:03  来源:igfitidea点击:

Read properties file using javascript

javascriptproperties

提问by Rachel

  • I have a db.properties file in my local machine with this value.
  • aaa = host,port,username,password
  • I have a jsp page with button. On click of a button i need to read properties file value(aaa = host,port,username,password) using javascript
  • 我的本地机器中有一个 db.properties 文件,具有此值。
  • aaa = 主机、端口、用户名、密码
  • 我有一个带按钮的jsp页面。单击按钮时,我需要使用 javascript 读取属性文件值(aaa = 主机、端口、用户名、密码)

回答by shashank

Include the MessageResource.js from herethis will solve the problem if you are using a simple javascript.

如果您使用的是简单的 javascript,则从此处包含 MessageResource.js这将解决问题。

If you are using any script framework it will contain inbuilt functionality to read .properties files. For Example, SAPUI5 contains oBundle functionality to do this.

如果您使用任何脚本框架,它将包含读取 .properties 文件的内置功能。例如,SAPUI5 包含 oBundle 功能来执行此操作。