问题
I am sending an arrayList from a java file to a .jsp file
In order to receive that array I used the following code
var words =
[
<c:forEach begin="0" items="${requestScope.WordList}" var = "word">
word,
</c:forEach>
];
however it is not working .. any Idea of how to do it ?
回答1:
Possible fix (Bad fix):
var words =
[
<c:forEach items="${requestScope.WordList}" var="word"
varStatus="status">
"${word}"<c:if test="${not status.last}">,</c:if>
</c:forEach>
];
OR
Convert the Java ArrayList
to JSON
String, and use JSON.parse()
to get Javascript object.
来源:https://stackoverflow.com/questions/16133264/convert-arraylist-to-javascript-array