场景:
<form method="post" action="go.do">
〈table>
<tr>
<td><input type="text" name="ab.name" value="10"></td>
<td><input type="text" name="ab.url" value="www.iteye.com"></td>
</tr>
<tr>
<td><input type="text" name="ab.name" value="20"></td>
<td><input type="text" name="ab.url" value="www.google.com"></td>
</tr>
</table>
<input type="submit" value="submit">
</form>
用struts在后台设了List<SP> sp获取。
sp的结果如下:
10 null
20 null
null www.iteye.com
null www.google.com
我想得到的结果是
10 www.iteye.com
20 www.google.com
请问各位大神怎么实现
貌似得这么写,你可以试试
〈table>同一个表单 你就不应该有name相同的东西.另外你的name和url是什么关系.这样写input的原因何在?
楼上说的很有道理啊,要说的是,
你第二个tr完全是多余的,表单上一般要拿的实体都是一个,比如修改页面,新增页面等,之所以产生以下结果,
sp的结果如下:
10 null
20 null
null www.iteye.com
null www.google.com
是因为你要两个一模一样的name,那么这样就不知道要拿哪个的,对应不上。
反射搞定啊