我在对象中有字符串数组值,request
我像下面这样检索它,
<%
if (request.getAttribute("categoriesList") != null) {%>
<input id="categoriesList" name="categoriesList" type="hidden" value="<%= (String[]) request.getAttribute("categoriesList") %>"/>
<c:forEach var="categoryName" items="${categoriesList}">
<li><a onclick="getCategoryIndex()" href="#">${categoryName}</a></li>
</c:forEach>
<% }%>
这会将值打印到,<li>
但我也有隐藏变量,我想将值分配给它,
<input id="categoriesList" name="categoriesList" type="hidden" value="<%= (String[]) request.getAttribute("categoriesList") %>"/>
但是当我使用如下的java脚本打印它们时,
var category= new Array();
category = $('#categoriesList').val();
console.log(category);
for (var i in category) {
console.log(category[i]);
}
我明白了,
[Ljava.lang.String;@f2bc8d rechargeWalletRequest.htm:182
[ rechargeWalletRequest.htm:186
L rechargeWalletRequest.htm:186
j rechargeWalletRequest.htm:186
a rechargeWalletRequest.htm:186
v rechargeWalletRequest.htm:186
a rechargeWalletRequest.htm:186
. rechargeWalletRequest.htm:186
l rechargeWalletRequest.htm:186
a rechargeWalletRequest.htm:186
n rechargeWalletRequest.htm:186
g rechargeWalletRequest.htm:186
. rechargeWalletRequest.htm:186
S rechargeWalletRequest.htm:186
t rechargeWalletRequest.htm:186
r rechargeWalletRequest.htm:186
i rechargeWalletRequest.htm:186
n rechargeWalletRequest.htm:186
g rechargeWalletRequest.htm:186
; rechargeWalletRequest.htm:186
@ rechargeWalletRequest.htm:186
f rechargeWalletRequest.htm:186
2 rechargeWalletRequest.htm:186
b rechargeWalletRequest.htm:186
c rechargeWalletRequest.htm:186
8 rechargeWalletRequest.htm:186
d rechargeWalletRequest.htm:186
我应该得到价值,但它会打印其他东西。
请帮助完成这项工作。