Read properties file using jQuery or JavaScript

后端 未结 4 827
野的像风
野的像风 2020-12-19 13:54

I am newbie in jquery. I would like to read Java properties file in my jsp page using javascript or jquery. I\'m goggling about it but not satisfied.

My applicatio

4条回答
  •  悲&欢浪女
    2020-12-19 14:09

    You can load properties with javascript using messageResource.js library created by me.

    1) Include messageResource.js.

    
    

    2) Change javascript as follows.

    // initialize messageResource.js  
    messageResource.init({
        // path to directory containing properties files
        filePath : 'path/resource'
    });
    
    function checkedRadioForDelete(f) {
    
        // get values from properties files
        var confirmMsg = messageResource.get('msg.confirm', 'fileName');
        var alertMsg = messageResource.get('msg.alert', 'fileName');
    
        var chx = document.getElementsByTagName('input');
        for ( var i = 0; i < chx.length; i++) {
            if (chx[i].type == 'radio' && chx[i].checked) {
                var con = confirm(confirmMsg);
                if (con != true) {
                } else {
                    f.action = "MyAction.action";
                    f.submit();
                }
                return true;
            }
        }
        alert(alertMsg);
        return false;
    }
    

提交回复
热议问题