我正在使用&#34创建表单;添加行"项目和使用AutoPopulatingList for spring。我从基本开始只用了一行。
我有模特:
ContractEntitlement.java
public class ContractEntitlement {
private String category;
getter and setter ....
}
我为AutoPopulatingList创建了一个表单类:
CreateForm.java
@Entity
public class CreateForm {
private AutoPopulatingList contractEntitlements;
public AutoPopulatingList getContractEntitlements() {
return contractEntitlements;
}
public void setContractEntitlements(AutoPopulatingList contractEntitlements) {
this.contractEntitlements = contractEntitlements;
}
}
对于我的控制器:
CreateController.java
@RequestMapping(value = "/create", method = RequestMethod.GET)
public String createForm(Model model) {
CreateForm createForm = new CreateForm();
// CreateForm sbf = new CreateForm();
// //sbf.getContractEntitlements().add(new ContractEntitlement());
// sbf.setContractEntitlements(new
// AutoPopulatingList(ContractEntitlement.class));
return "create";
}
对于我的jsp
Create.jsp
<spring:bind path="createForm.contractEntitlements[0].category">
<form:input path="${status.expression}" size="40" />
</spring:bind>
请注意,在我的控制器中,我已经注释了几行代码,因为我正在测试哪个代码可以运行,但都失败了,我收到了这个错误:
org.springframework.beans.NotReadablePropertyException: Invalid property 'contractEntitlement' of bean class [com.at.ccts.model.CreateForm]: Bean property 'contractEntitlement' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
如果我在我的控制器中使用它
CreateForm sbf = new CreateForm();
sbf.setContractEntitlements(new
AutoPopulatingList(ContractEntitlement.class));
错误:
ERROR: org.springframework.web.servlet.tags.form.InputTag - Invalid property 'contractEntitlement' of bean class [com.at.ccts.model.CreateForm]: Bean property 'contractEntitlement' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
我错过了什么吗?是什么原因导致错误?