我有一个 spring-mvc jsp 表,其中包含一些输入元素,以便能够进行一些过滤。thead 确实有一个作为子第一个元素的表单。
<table>
<thead>
<form:form action="." modelAttribute="accountWrapper.theAccount">
<tr><td class="columhead" id="firstname"><div class="disp">first name</div>
<div class="filter"><form:input path="firstName"/></div></td>
<td class="columnhead" id="lastname"><div class="disp">last name</div>
<div class="filter"><form:input path="lastName"/></div></td>
<td>email</td></tr>
</form:form>
</thead>
<tbody>
检查来源时,我看到:
<thead>
<form id="accountWrapper.theAccount" action="." method="post">
<tr><td class="columhead" id="firstname"><div class="disp">first name</div>
<div class="filter"><input id="theAccount.firstName" name="theAccount.firstName" type="text" value="search"/></div></td>
<td class="columnhead" id="lastname"><div class="disp">last name</div>
<div class="filter"><input id="theAccount.lastName" name="theAccount.lastName" type="text" value="search"/></div></td>
<td>email</td></tr>
</form>
</thead>
<tbody>
正如我所期望的那样。
但是当我检查 javascript DOM 时,表单元素是 <thead> 正下方的空元素, <input> 元素在表单之外。并且表单提交出错。
<thead>
<form id="accountWrapper.theAccount" action="." method="post"></form>
<tr><td class="columhead" id="firstname"><div class="disp">first name</div>
<div class="filter"><input id="theAccount.firstName" name="theAccount.firstName" type="text" value="search"/></div></td>
<td class="columnhead" id="lastname"><div class="disp">last name</div>
<div class="filter"><input id="theAccount.lastName" name="theAccount.lastName" type="text" value="search"/></div></td>
<td>email</td></tr>
</thead>
<tbody>