How to read a properties file in javascript from project directory?

前端 未结 5 1447
你的背包
你的背包 2020-12-05 15:23

I\'m building a Chrome Packaged App. I want to put the script configuration if a config file in a resource directory and on startup want to read that by Javascript.

5条回答
  •  暖寄归人
    2020-12-05 15:58

    It is pretty simple with JSF, but you will have to modify the HTML file every time you need a new parameter to be read from JavaScript. My property file (config.properties) in project directory has the following parameter as a key value pair.

    parameter.key=parameter.value
    

    The property file name is configured in faces-config.xml

    
        
            com.example.project.properties.config
            configuration
        
    
    

    Therefore, you can use a property value in a hidden input inside the HTML file.

    
    

    And from JavaScript function, use the following line to read the parameter value.

    var parameter_value = document.getElementById("parameter_key").value;
    

    Enjoy your day..!!!

提交回复
热议问题