struts2中Action怎样获取动态表单中的多行数据?

DimPasser DimPasser 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的页面如下,每点击一次“添加”按钮就生成一行表格,当所有信息输入完毕后点击“提交”按钮将值传给Action。如果行数已经确定的话可以在Action中通过get()方法来获取,但现在行数不确定,请教大家如何在Action中获取到这多行数据?
我的HTML代码如下:

<html>
<head>
<script type="text/javascript">
$().ready(function(){

//添加学生
$("#bt_add").click(function(){
var tr = $("#datalist table tbody:last-child");
//alert($("#datalist table tbody:last-child").html());
$("#datalist table").append($(".trmodel").clone().show().removeClass());
});

$(".delete").live('click',function(){
$(this).parents("tr").animate({ opacity: 'hide', left:'+250px', top:'-120px' }, 1000);
});
});
</script>
</head>
<body>
<div id="title">
<h2>添加学生</h2>
<div>
入学年份 <select style="width:80px;"><option>2008</option></select>
系别 <select style="width:150px;"><option>计算机与科学系</option></select>
班级 <select style="width:150px;"><option>90812P</option></select>
<span class="buttons">
<input type="button" value="提交" />
<input type="button" value="添加" id="bt_add" />
</span>
</div>
</div>

<div style="clear:both;"></div>
<!--表格样式-->
<div id="datalist">

<table>
<thead>
<td width="20%">学号</td>
<td width="20%">学生姓名</td>
<td width="10%">性别</td>
<td width="20%"></td>
</thead>
<tbody>
<tr style="">
<td align="left"><input type="text" value="" /></td>
<td align="left"><input type="text" value="" /></td>
<td>
<label>
<input type="radio" name="RadioGroup1" value="男" id="RadioGroup1_0" checked="checked" class="input_align_5"/>
男</label>
<label>
<input type="radio" name="RadioGroup1" value="女" id="RadioGroup1_1" class="input_align_5" />
女</label>
</td>
<td></td>
</tr>

<tr style=" display:none;" class="trmodel">
<td align="left"><input type="text" value="" /></td>
<td align="left"><input type="text" value="" /></td>
<td>
<label>
<input type="radio" name="RadioGroup1" value="男" id="RadioGroup1_0" checked="checked" class="input_align_5"/>
男</label>
<label>
<input type="radio" name="RadioGroup1" value="女" id="RadioGroup1_1" class="input_align_5" />
女</label>
</td>
<td><a href="#" class="delete"> 删除</a></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

页面如下:
...全文
评论 18
收藏 已收藏
分享
返回顶部
DimPasser
Web 开发 81,107 成员 341,720 内容