当前位置:编程学习 > JAVA >>

获取list个数。。。


<input type="hidden" name="SomeList">
<input type="hidden" name="SomeList[0].id" value="111">
<input type="hidden" name="SomeList[0].name" value="aaa">
<input type="hidden" name="SomeList[1].id" value="222">
<input type="hidden" name="SomeList[1].name" value="bbb">
<input type="hidden" name="SomeList[2].id" value="333">
<input type="hidden" name="SomeList[2].name" value="ccc">


怎么获取list中有3条数据,参数都是页面传过来的 --------------------编程问答-------------------- for(int i=0; i<3; i++){
System.out.println(request.getParameter("SomeList["+i+"].id"));
System.out.println(request.getParameter("SomeList["+i+"].name"));
} --------------------编程问答--------------------
引用 1 楼 huxiweng 的回复:
for(int i=0; i<3; i++){
System.out.println(request.getParameter("SomeList["+i+"].id"));
System.out.println(request.getParameter("SomeList["+i+"].name"));
}


关键是我不知道有3条啊
 这个是不固定的 --------------------编程问答-------------------- 用jstl的foreach做,不会的话可以google一下 --------------------编程问答--------------------
引用 3 楼 a470577391 的回复:
用jstl的foreach做,不会的话可以google一下


我不可能在传参的页面也加任何代码 你说的 大概是在JSP页面<% %>这样循环获取值

我这个页面是不可能修改 --------------------编程问答-------------------- 你不能修改这个页面是啥意思 --------------------编程问答--------------------  大神呢
 

引用 5 楼 mmqw1122 的回复:
你不能修改这个页面是啥意思


意思是 页面是传过来的  我只负责取值 --------------------编程问答-------------------- list的个数不确定,那这个list的数量应该是根据别处传到这个jsp里面的什么值确定的吧,你可以看到页面的代码吗?可以发下不,上面那个代码说明不了什么 --------------------编程问答--------------------
引用 7 楼 a470577391 的回复:
list的个数不确定,那这个list的数量应该是根据别处传到这个jsp里面的什么值确定的吧,你可以看到页面的代码吗?可以发下不,上面那个代码说明不了什么


这就是传过来的JSP页面   
大概思路只能获取name为SomeList的个数  然后除以3   3个为一组  只能这么做了
补充:Java ,  Java相关
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,