我在Spring MVC 3项目中使用百里香。 这是我的表格
<form id="idenForm" th:object="${identifierBean}"
th:action="@{/spring/addIndentifier}" method="get">
<table>
<tr>
<td>Identifier Number:</td>
<td><input type="text" th:field="*{idNumber}" id="idNumber"
name="idNumber" /></td>
<td>Issue Location:</td>
<td><input type="text" th:field="*{issueLocation}"
id="issueLocation" name="issueLocation" /></td>
</tr>
<tr>
<td>Issue Date:</td>
<td><input type="text" th:field="*{issueDate}"
th:class="datepicker" id="issueDate" name="issueDate" /></td>
<td>Expiry Date:</td>
<td><input type="text" th:field="*{expiryDate}"
th:class="datepicker" id="expiryDate" name="expiryDate" /></td>
</tr>
<tr>
<td>
<button id="idenButton" name="idenButton"
onclick="doAjaxCallIdentifier()" type="button">Add
Identifier</button>
</td>
</tr>
</table>
</form>
这是我的javascript函数
<script type="text/javascript">
function doAjaxCallIdentifier() {
var idNumber = $('#idNumber').val();
var issueLocation = $('#issueLocation').val();
var issueDate = $('#issueDate').val();
var expiryDate = $('#expiryDate').val();
var formData=$("#idenForm").serialize();
alert(formData);
var url='/SpringUI/spring/addIndentifier';
$("#content").load(url,data);
}
当我序列化表单时,我在警告框中得到空白数据。我无法理解问题。 这是表单的html版本
<form id="idenForm" method="get" action="/SpringUI/spring/addIndentifier">
<table>
<tr>
<td>Identifier Number:</td>
<td><input type="text" id="idNumber" name="idNumber" value="" /></td>
<td>Issue Location:</td>
<td><input type="text" id="issueLocation" name="issueLocation" value="" /></td>
</tr>
<tr>
<td>Issue Date:</td>
<td><input type="text" id="issueDate" name="issueDate" class="datepicker" value="" /></td>
<td>Expiry Date:</td>
<td><input type="text" id="expiryDate" name="expiryDate" class="datepicker" value="" /></td>
</tr>
<tr>
<td>
<button id="idenButton" name="idenButton" onclick="doAjaxCallIdentifier()" type="button">Add
Identifier</button>
</td>
</tr>
</table>
</form>