我希望在提交表单时将html表中的值(从每一行)获取到servlet。怎么做到呢?请帮我解决一下。
<form name="form1" action="serv" method="POST">
<table border="1">
<thead>
<tr>
<th>NAME</th>
<th>AGE</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev</td>
<td>13</td>
</tr>
<tr>
<td>Shartt</td>
<td>15</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="SUBMIT" name="submit" /></td>
</tr>
</tbody>
</table>
</form>
答案 0 :(得分:0)
在您的HTML中,您没有任何表单元素。试试这样的事情:
<form name="form1" action="serv" method="POST">
<table border="1">
<thead>
<tr>
<th>NAME</th>
<th>AGE</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev</td>
<td><input type="text" name="age" value="13"></td>
</tr>
<tr>
<td>Shartt</td>
<td><input type="text" name="age" value="13"></td>
</tr>
<tr>
<td clospan="2"><input type="submit" value="SUBMIT" name="submit" /></td>
</tr>
</tbody>
</table>
</form>