How does javaScript handle a list returned from the Java background

  • 2020-03-30 02:41:49
  • OfStack

Things:

Return List< from Java background; String> Type data for interface display. But js wants to get it and manipulate it. Using the EL expression directly, js recognizes it as a string. It's not what I wanted. Searched for solutions on the Internet... The best thing, of course, is to turn the List collection into json and upload it to the interface. So js inside the operation is simple, the page is not affected.

Solution:

Will List< String> Json to the interface. Var arr = eval (' ${list}'); Turn the list into a js array.

My code:
 
var keyList = eval('${keysList}'); 
var values = $("#paramsValues").val(); 

var noSet = []; 

for(var i=0;i<keyList.length;i++){ 
if(values.indexOf(keyList[i])==-1){ 
noSet.push(keyList[i]); 
} 
} 

Related articles: