一张是类别信息表,另外一张是基本信息表,在基本信息添加时,类别是一个下拉框进行选择,并把类别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>下面是action的处理方法,typeId获取到值了,newInsuranceType.getName()也有值,但是这里因为取的一条记录,所以返回值是typeBean里面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;
}
}请问我改如何解决这个问题,谢谢
下面是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>下面是action的处理方法,typeId获取到值了,newInsuranceType.getName()也有值,但是这里因为取的一条记录,所以返回值是typeBean里面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;
}
}请问我改如何解决这个问题,谢谢
解决方案 »
- spring整合xfire添加数据问题
- 关于留言的设置
- tomcat启动不起来?
- 请告诉我怎么调用不到ejbStore()
- Struts的action问题
- Linux下的rmic出现如下编译错误,大家给看看。谢谢了,在Windows下命令行编译通过,并正常运行。
- 急!!! 用jbuild和websphere集成,ear包打好后,用jb的 tools 下的server deployment 工具发布问题
- struts问题!
- 我已昏了。快来帮帮我,关于EJB的调用问题
- SSM框架插入数据 和批量插入数据报错 求大神 给解答。。。。。。。。。。。
- 有高手帮我看下嘛? lucene的问题
- jsp引入jquery
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;
}
}
页面可以不用改了,还是那样取的,LZ试试吧,不行了再问我