How to set the JSTL variable value in javascript?

后端 未结 8 2122
我在风中等你
我在风中等你 2020-11-27 16:56

How to set the JSTL variable value in java script?



        
8条回答
  •  囚心锁ツ
    2020-11-27 17:49

    As an answer I say No. You can only get values from jstl to javascript. But u can display the user name using javascript itself. Best ways are here. To display user name, if u have html like

    You can display user name as follows.

    var val1 = document.getElementById('userName').value;
    document.getElementById('uName').innerHTML = val1;
    

    To get data from jstl to your javascript :

    var userName = '';
    

    here ${user} is the data you get as response(from backend).

    Asigning number/array length

    var arrayLength = ;
    

    Advanced

    function advanced(){
        var values = new Array();
        
           values.push("No user found"); 
                 
    
        
            
                values.push("${user.name}");   
            
        
        alert("values[0] "+values[0]);
    
    }); 
    

提交回复
热议问题