转换的ArrayList到JavaScript数组 [英] Convert arrayList to javascript array
本文介绍了转换的ArrayList到JavaScript数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我送从Java文件一个ArrayList一个.jsp文件
I am sending an arrayList from a java file to a .jsp file
为了获得这个数组我用下面的code
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 ?
推荐答案
可能的修正(错误修复):
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>
];
或
转换了Java 的ArrayList
到 JSON
字符串,并使用 JSON.parse()来
来获取JavaScript对象。
Convert the Java ArrayList
to JSON
String, and use JSON.parse()
to get Javascript object.
这篇关于转换的ArrayList到JavaScript数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文