对象列表的spring绑定
我有这个结构的目标 公厕清洁{对象列表的spring绑定,spring,data-binding,Spring,Data Binding,我有这个结构的目标 公厕清洁{ private Contacts contact; private List<Contacts> dnb360; private String operation; public String getOperation() { return operation; } public void setOperation(String operation) { this.operation = operation; } public
private Contacts contact;
private List<Contacts> dnb360;
private String operation;
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public Contacts getContact() {
return contact;
}
public void setContact(Contacts contact) {
this.contact = contact;
}
public List<Contacts> getDnb360() {
return dnb360;
}
public void setDnb360(List<Contacts> dnb360) {
this.dnb360 = dnb360;
}
私人联系人;
私人名单dnb360;
私有字符串操作;
公共字符串getOperation(){
返回操作;
}
公共void设置操作(字符串操作){
这个操作=操作;
}
公共联系人getContact(){
回接;
}
公共联系人(联系人联系人){
this.contact=contact;
}
公共列表getDnb360(){
返回dnb360;
}
公共无效设置dnb360(列表dnb360){
此参数为0.dnb360=dnb360;
}
在jsp中,我得到了清理对象的列表
有谁能告诉我如何绑定此列表并在contoller中获取提交的值在jsp中绑定并不是那么困难。如果您使用的是核心jstl标记(您应该这样做),您只需迭代列表条目,然后根据需要对其进行处理:
<c:forEach items="${dnb360}" var="s">
<b>${s}</b>
</c:forEach>
如果您需要更多帮助,请随时询问。如果您没有进行数据库调用,并且这是控制器的一个帖子,您如何处理?您的setAsText函数不处理列表项。您能告诉我如何处理列表项吗?您可以在这里看到我的问题
<form:checkboxes items="${dnb360}" path="dnb360" />
@InitBinder
public void initBinder(WebDataBinder binder) {
//custom editor to bind Institution by name
binder.registerCustomEditor(Contacts.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(xxx); //most likely obtained through database call
}
});
}