如何在url中传递一个字符串数组 [英] How to pass an array of string in a url

查看:2161
本文介绍了如何在url中传递一个字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我的jsp中有一个url,我想在这个url中传递一个字符串数组,以便在我的ActionForm中恢复

Hello i have an url in my jsp and i want to pass an array of string in this url to recover in my ActionForm

推荐答案

您可以使用'标准'html方式传递数据数组: http:// mywebsite / mypage?myarray = value1& myarray = value2& myarray = value3 。然后,您可以从请求对象中获取参数 myarray 的所有值(如果框架不提供更优雅的数组处理方式)。

You can use 'standard' html way of passing arrays of data: http://mywebsite/mypage?myarray=value1&myarray=value2&myarray=value3. Then you can fetch all values of parameter myarray from request object (if framework doesn't provide more elegant ways of handling arrays).

但是看到你的评论,我建议你留下JavaScript并为它声明一个表格。

如果你需要一个链接(不是按钮),你总是可以从中提交表格。像< a href =javascript:$('#myForm')。submit();> ...< / a>

But seeing your comment, I would recommend to leave JavaScript and just declare a form for it.
If you need a link (not button), you can always submit form from it. Something like <a href="javascript:$('#myForm').submit();">...</a>

这篇关于如何在url中传递一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆