我需要从 jsp 传递下面的数组 [aLocations]。
<script type="text/javascript">
var aLocations = new Array();
var aTitles = new Array();
var aDetails = new Array();
aLocations = ['keswick,cumbria,uk','grasmere,cumbria,uk','ambleside,cumbria,uk'];
</script>
如果我这样尝试,它不起作用:
<%
ArrayList<String> myArr = new ArrayList<String>();
myArr.add("keswick,cumbria,uk");
myArr.add("grasmere,cumbria,uk");
myArr.add("ambleside,cumbria,uk");
%>
<script type="text/javascript">
var aLocations = new Array();
var aTitles = new Array();
var aDetails = new Array();
aLocations = <%=myArr%>;
</script>
从 JSP 传递的最佳方法是什么?