这是我的 JSP 代码片段,它会导致错误
<form:select path="bankDetails[0].applicantType">
<form:option value="Applicant">Applicant</form:option>
<form:option value="Co-Applicant 1">Co-Applicant 1</form:option>
<form:option value="Co-Applicant 2">Co-Applicant 2</form:option>
<form:option value="Co-Applicant 3">Co-Applicant 3</form:option>
<form:option value="Guarantor 1">Guarantor 1</form:option>
<form:option value="Guarantor 2">Guarantor 2</form:option>
<form:option value="Guarantor 3">Guarantor 3</form:option>
</form:select>
这是我的控制器代码
@RequestMapping(value = "enterBankDetails.htm", method = RequestMethod.GET)
public ModelAndView enterBankDetails() {
functionName = "enterBankDetails";
logger.info("In "+className+" - "+functionName+" ");
BankDetails details = new BankDetails();
ArrayList<EntityBankDetail> entitityBankDetails = new ArrayList<EntityBankDetail>();
for(int i = 0 ; i < 4 ;i++){
EntityBankDetail entityBankDetail = new EntityBankDetail();
entitityBankDetails.add(entityBankDetail);
}
details.setBankDetails(entitityBankDetails);
return new ModelAndView("bankDetails/bankDetails", "command",details);
}
这是bean代码
public class BankDetails {
private ArrayList<EntityBankDetail> bankDetails;
private String[] entities;
private int noOfBankDetails;
private String test;
//getter and setter methods
}
public class EntityBankDetail {
private String nameOfBank;
private String EMIforProposedLoan;
private String nameOfBranch;
private String city;
private String accountType;
private String accountNumber;
private String applicantType;
//getter and setter methods
}
我收到以下错误
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'bankDetails[0]' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
请帮忙。我不知道我在做什么错?
编辑:当我将它绑定到测试时也会发生同样的情况
<form:select path="test">
<form:option value="Applicant">Applicant</form:option>
<form:option value="Co-Applicant 1">Co-Applicant 1</form:option>
<form:option value="Co-Applicant 2">Co-Applicant 2</form:option>
<form:option value="Co-Applicant 3">Co-Applicant 3</form:option>
<form:option value="Guarantor 1">Guarantor 1</form:option>
<form:option value="Guarantor 2">Guarantor 2</form:option>
<form:option value="Guarantor 3">Guarantor 3</form:option>
</form:select>
Neither BindingResult nor plain target object for bean name 'test' available as request attribute