一张是类别信息表,另外一张是基本信息表,在基本信息添加时,类别是一个下拉框进行选择,并把类别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;
}
}请问我改如何解决这个问题,谢谢
解决方案 »
- 关于form表单的问题
- 关于createInstall Free的运行配置问题
- 真心求教:怎样在根据已有的数据库生成ejb3.0的实体bean和dao
- <bean:write>标签读值的问题
- web 服务中使用相对路径
- 如何将JAVA代码、及其相关,整体“.EXE”化!(急急急)
- 很傻的问题
- 求救!jdbc原来连接上SQLserver,但是改动ip之后,报错Error establishing socket!
- 高分请教Weblogic的配置部署问题
- 请问我写了一个ejb和相应接口要放在什么目录下,客户端才能找到?
- 求解:Tomcat启动时,其catalina.out文件老是有错,但是应用还是能正常访问。
- SSH整合问题(紧急求助)
你应该把所有的newInsuranceType取出来,然后在页面用struts2的表达式做一个比较.
private String name ;
//getter 和 setterpublic 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);
if (newInsuranceType != null){
name = newInsuranceType.getName() ;
}else{
name = "NULL" ;
} System.out.println("// Debug name = " + newInsuranceType.getName());
}
}
}
return "list";
}catch (Exception e) {
log.error(e.getMessage(), e);
return ERROR;
}
}
<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='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>