在JSP页面中是这样定义的:
[code="HTML"]
${c.name}
style="background-color: #F7F7F7;" value=""/>
/c:forEach
[/code]
在Action类中
[code="java"]
private CrmBusinessProduct model;
private CrmBusinessProduct[] models; //得到业务机会产品数值
public CrmBusinessProduct[] getModels() {
return models;
}
public void setModels(CrmBusinessProduct[] models) {
this.models = models;
}
public String save() throws Exception {
if(subBox == null){
addActionError("参数错误!");
return ADDTWO;
}
if(StringUtils.isEmpty(this.bid)) {
addActionError("参数错误!");
return ADDTWO;
}
if(null == models){
addActionError("参数错误!");
return ADDTWO;
}
CrmBusiness crmBusiness = this.crmBusinessService
.getObjectBusiness(this.bid);
if (null == crmBusiness) {
addActionError("参数错误!");
return ADDTWO;
}
//循环添加产品数据
for(int i=0;i<subBox.length;i++){
this.crmProduct=this.crmProductService.get(subBox[i]);
this.crmBusiness= this.crmBusinessService.getObjectBusiness(this.bid);
this.models[i].setTenantID(this.getCurrenTenantID());
this.models[i].setBusinessID(crmBusiness.getId());
this.models[i].setBusinessName(crmBusiness.getBussName());
this.models[i].setProductID(crmProduct.getId());
this.models[i].setProductName(crmProduct.getName());
this.models[i].setProductTypeID(crmProduct.getProductTypeID());
this.models[i].setQuantity(models[i].getQuantity());
this.models[i].setDescription(models[i].getDescription());
this.models[i].setPrice(crmProduct.getPrice());
this.models[i].setCostPrice(models[i].getPrice());
this.models[i].setDate(this.models[i].getDate());
this.models[i].setCreateDate(new Date());
this.models[i].setModifyDate(new Date());
this.crmBusinessProductService.insert(this.models[i]);
}
// 2.保存自定义数据
if (null != this.getModelColumnList()) {
CrmColumnDefineData data = null;
for (CrmColumnDefine o : this.modelColumnList) {
data = new CrmColumnDefineData();
String columnVal = request.getParameter(o.getId());
data.setColumnId(o.getId());
data.setTargetId(this.model.getId());
data.setTenantId(this.model.getTenantID());
data.setValue(columnVal);
this.crmColumnDefineService.storeColumnData(data);
}
}
this.id = this.model.getId();
if (this.btnType.equals("save")) {
return SUCCESS;
} else if (this.btnType.equals("save_new")) {
return add();
}
return SUCCESS;
}
[/code]
为什么models我用debug测试 models为空是什么原因?