控制器
@RequestMapping(value = "/chartofaccount", method = RequestMethod.GET)
public String getChartofAccount(Model model) {
try {
List CoaCategoryList = new ArrayList();
COACategoriesModel obj;
List<COACategoriesModel> getCoaCategoryList = coaCategoriesService
.getAllCOACategories();
if (getCoaCategoryList.size() > 0) {
for (int i = 0; i < getCoaCategoryList.size(); i++) {
obj = getCoaCategoryList.get(i);
CoaCategoryList.add(obj.getId());
CoaCategoryList.add(obj.getName());
model.addAttribute("list", CoaCategoryList);
}
}
} catch (Exception ex) {
log.error("Exception.." + ex);
}
return "fin/coa";
}
鳍/coa.jsp
<ct:Select setIdentity="coaCategoryId" list="${list}" selected="0" />
上面的列表成功填充,在我的自定义标签中。
but
另一个控制器
@RequestMapping(value = "/addCoaMaintenance", method = RequestMethod.POST)
public String addCoaCategory(
@RequestParam("mainAccount") long mainAccount,
@RequestParam("subAccount") long subAccount,
@RequestParam("accountName") String accountName,
@RequestParam("coaCategoryId") long coaCategoryId,
@RequestParam("postingType") int postingType,
@RequestParam("typicalBalance") int typicalBalance,
@RequestParam("isActive") int isActive,
Model model) {
Date sysdate = null;
String Message="";
try{
sysdate = new Date();
Message="Operation Fail!";
COAMaintenanceModel coaMaintenanceModel= new COAMaintenanceModel(mainAccount, subAccount, accountName, coaCategoryId, postingType, typicalBalance, isActive, GetSessionValue.getSysUserId(), GetSessionValue.getSysUserIp(), sysdate, 0);
coaMaintenanceService.AddCOAMaintenance(coaMaintenanceModel);
Message="Account Save Successfully";
model.addAttribute("result_success", Message);
}catch(Exception ex){
log.error("Exception.."+ex);
model.addAttribute("result_fail", Message);
}
return "fin/coa";
}
作为第二个控制器返回fin/coa.jsp,列表为空。如何控制这个?我正在使用spring Mvc + hibernate。在我需要之前,如何使第一个控制器列表可用。