Convert arrayList to javascript array

I am sending a List array from a java file to a .jsp file

To get this array, I used the following code

var words = [ <c:forEach begin="0" items="${requestScope.WordList}" var = "word"> word, </c:forEach> ]; 

however it does not work. Any idea on how to do this?

0
source share
1 answer

Possible fix (incorrect correction):

 var words = [ <c:forEach items="${requestScope.WordList}" var="word" varStatus="status"> "${word}"<c:if test="${not status.last}">,</c:if> </c:forEach> ]; 

OR

Convert Java ArrayList to JSON String and use JSON.parse() to get a Javascript object.

+1
source

All Articles