日期:2014-05-17  浏览次数:21079 次

c:forEach和EL表达式
<c:forEach var="fhd" items="${fhd_ListArray}" >
<tr>
<td>
<input type="text" value="${fhd.sptm}" />
</td>
<td>
<input type="text" value="${fhd.spmc}" />
</td>
<td>
<input type="text" value="${fhd.gj}" />
</td>
<td>
<input type="text" value="${fhd.fhzs}" />
</td>
</tr>
</c:forEach>
为什么会取不到值?fhd_ListArray装的是实体bean,有四个属性.
这个页面对应的Servlet中request.setAttribute("fhdList", fhd_ListArray);有没有问题?

------解决方案--------------------
<c:forEach var="fhd" items="${fhdList}" >
 
------解决方案--------------------
要改成items="fhdList"
------解决方案--------------------
el表达式中取值是以键为索引,也就是说${}中应该写的是setAttribute中的第一个参数"fhdList"

按一楼的方式写应该是没问题的