action向jsp页面传数组,在jsp中怎么接收???

www_shenrenxue_com www_shenrenxue_com 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Java Code:

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
String[] arr = { "1", "3", "5" };
request.setAttribute("arr", arr);
return new ActionForward("/index.jsp");
}

Jsp页面:
<body>
<script type="text/javascript">
function getArr(){
var arr = '<%=request.getParameterValues("arr")%>';
for(var i=0;i<arr.length;i++){
alert(arr[i]);
}


}


</body>

跟我想的不一样啊,怎么打出来的都是undefined...而且length是27不是3,为什么?

...全文

相关推荐

评论 17
收藏 已收藏
分享
返回顶部
www_shenrenxue_com
Web 开发 81,107 成员 341,720 内容