我有一個問題,我必須動態生成下拉框使用jQuery和彈簧綁定它們。我在我的表單支持對象中有一個列表,並試圖使用遞增的計數器來綁定它。JQuery動態選擇彈簧綁定
我收到follwoing錯誤:
org.springframework.beans.InvalidPropertyException: Invalid property 'selectedPermntRestrictCat[ + categoryCounter + ]' of bean class [com.portal.policymanagement.formObject.EditPolicyFormObject]: Invalid index in property path 'selectedPermntRestrictCat[ + categoryCounter + ]'; nested exception is java.lang.NumberFormatException: For input string: " + categoryCounter + "
$(document).ready(function(){
var categoryCounter=0;
$('#addCategory').click(function() {
$('<div class="holder"><div class="left"><label> </label><form:select path="policy.selectedPermntRestrictCat[' + categoryCounter + ']"><form:option value="0" label="Select" /><form:option value="6" label="Entertainment" /><form:option value="7" label="Religion" /><form:option value="8" label="Weapons" /><form:option value="9" label="Virtual Community" /><form:option value="10" label="Hacking" /><form:option value="11" label="Search Engines" /><form:option value="12" label="Educational" /><form:option value="13" label="Other" /><form:option value="14" label="TEST NON_EXISTANT" /><form:option value="1" label="Violence" /><form:option value="2" label="Drugs" /><form:option value="3" label="Adult Content" /><form:option value="4" label="Online Resources" /><form:option value="5" label="Gambling" /></form:select></div><div class="right"><a id="'+i+'" class="but_default" href="#">Delete</a></div><div class="errors left"></div><div class="clear"></div></div>').fadeIn('slow').appendTo('.blockedCategories');
categoryCounter++;
});
});