[英]How to map two different model attribute to one table in jsp while updating the list in jsp page?
[英]How can a JSP page list two different beans in the same table?
我有一个带有此代码的.jsp
页面:
<tbody>
<c:forEach items="${companies}" var="companies">
<tr>
<td>${companies.id}</td>
<td>${companies.name}</td>
<td>${companies.email}</td>
<td>${companies.countryId}</td>
<td>${companies.sendToIdes}</td>
<td>${companies.senderId}</td>
</tr>
</c:forEach>
</tbody>
和此代码:
<tbody>
<c:forEach items="${countries}" var="countries">
<tr>
<td>${countries.id}</td>
<td>${countries.code}</td>
<td>${countries.name}</td>
<td>${countries.model}</td>
<td>${countries.hctaId}</td>
<td>${countries.certificate}</td>
<td>${countries.signature}</td>
</tr>
</c:forEach>
</tbody>
看到companies
有countryId
而countries
有id
,它们与那两个信息有关。
我需要插入一个countries.name
我内companies
与相关的id
和countryId
。
假设countries
是按国家/地区ID(即country.id
)索引的地图 ,则${countries[company.countryId].name}
将引用companies表中的国家/地区名称。
(顺便说一句,我建议您在c:forEach
变量声明中使用单数变量名称。例如,将var="companies"
更改为var="company"
,将var="countries"
更改为var="country"
。 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.