<script type="text/javascript"
src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
var rowCount = 1;
function addMoreRows() {
rowCount++;
alert("Hello "+rowCount);
var recRow = '<p id="rowCount'+rowCount+'">'
+ '<tr><td><form:input path="dynamicRow['+rowCount+'].id"/></td>'
+ '<td><form:input path="dynamicRow['+rowCount+'].name" /></td>'
+ '<td><form:input path="dynamicRow['+rowCount+'].email" /></td></tr>'
+ ' <a href="javascript:void(0);" onclick="removeRow('
+ rowCount + ');">Delete</a>' + '</p>';
$('#addedRows').append(recRow);
//$(document).trigger("addedNewRow", rowCount);
}
function removeRow(removeNum) {
$('#rowCount' + removeNum).remove();
rowCount--;
}
</script>
这是我在jsp页面中使用的脚本,但在运行时抛出错误
Invalid property 'dynamicRow[+rowCount]' of bean class [com.sharique.beans.DynamicRowForm]: Invalid index in property path 'dynamicRow[+rowCount]'; nested exception is java.lang.NumberFormatException: For input string: "+rowCount"
之前它正在运行,但在代码清理期间,我做了一些更改,之后开始抛出此异常。我不知道这里有什么错误。请帮助!!
答案 0 :(得分:0)
删除单引号和&#39; +&#39;在dynamicRow['+rowCount+']
内并检查。
设为dynamicRow[rowCount]