在线等解决,跨表属性获取值,在list页面显示
一张是类别信息表,另外一张是基本信息表,在基本信息添加时,类别是一个下拉框进行选择,并把类别ID存储在基本信息表中;现在我要显示基本信息List,其中一列显示类别名称,我想请教下,我该如何取得类别名称,并显示在list中,下面是我的处理代码,名称取出来了,但是页面显示没出来,请高手指点,谢谢!
下面是list的显示页面,<s:property value='newInsuranceType.name'/>这行代码没获取到值
<s:iterator value="newInsuranceList" id="newInsuranceList" status="index"><tr><td align="center"><%=n++ %></td><td align="center"><a href="infoNewInsurance.action?newInsurance.insuranceInformationId=<s:property value='#newInsuranceList.insuranceInformationId'/>" style="cursor:pointer;" target="_blank"><s:property value="#newInsuranceList.name"/></a></td><td align="center"><s:property value='newInsuranceType.name'/> </td><td align="center"><s:property value='#newInsuranceList.feeRate'/> </td><td align="center"><s:property value='#newInsuranceList.procedureRate'/> </td><td align="center"><s:property value='#newInsuranceList.directorDiscountRate'/> </td><td align="center"><s:property value='#newInsuranceList.managerDiscountRate'/> td></tr></s:iterator>
public String list(){try{ newInsuranceList = newInsuranceService.findAllByFlag(); int typeId = 0; if(newInsuranceList.size() > 0 && newInsuranceList != null){ for(int i = 0; i<newInsuranceList.size(); i++){ typeId = newInsuranceList.get(i).getTypeId(); System.out.println("// Debug typeId = " + typeId); if(typeId > 0){ newInsuranceType = newInsuranceTypeService.findById(typeId); System.out.println("// Debug name = " + newInsuranceType.getName()); } } } return "list";}catch (Exception e) {log.error(e.getMessage(), e);return ERROR;}}
public String list(){ try{ //创建一个新的 List List list = new ArrayList(); newInsuranceList = newInsuranceService.findAllByFlag(); int typeId = 0; if(newInsuranceList.size() > 0 && newInsuranceList != null){ for(int i = 0; i<newInsuranceList.size(); i++){ //创建一个 Map Map<String,Object> map = new HashMap<String,Object>(); //用对象接收 (Object ) typeId = newInsuranceList.get(i).getTypeId(); //加入页面要显示的值,依次得到你想要输出的值 map.put("feeRate",newInsuranceList.get(i).getFeeRate()); map.put("procedureRate",newInsuranceList.get(i).getProcedureRate()); map.put("directorDiscountRate",newInsuranceList.get(i).getDirectorDiscountRate()); map.put("managerDiscountRate",newInsuranceList.get(i).getManagerDiscountRate()); System.out.println("// Debug typeId = " + typeId); if(typeId > 0){ newInsuranceType = newInsuranceTypeService.findById(typeId); System.out.println("// Debug name = " + newInsuranceType.getName()); map.put("name",newInsuranceType.getName()); } list.add(map); } } return "list"; }catch (Exception e) { log.error(e.getMessage(), e); return ERROR; } }