+ -
当前位置:首页 → 问答吧 → 使用EL表达式forEach遍历list,结果输出是重复行

使用EL表达式forEach遍历list,结果输出是重复行

时间:2011-08-27

来源:互联网

各位大虾:
            江湖急救!小弟使用了EL表达式forEach遍历list,此list有三行不同的记录,每行有五列。页面使用的程序如下:

得到的                         List   list   =   facade.getUserList(parameters);
request.setAttribute( "userList ",list);


            <table   id= "userManagetable ">
      <tr>
          <th> 用户账号 </th>
          <th> 用户名称 </th>
          <th> 密码 </th>
          <th> 性别 </th>
          <th> 生日 </th>
      </tr>
      <c:forEach   items= "${requestScope.userList} "   var= "person ">
      <tr>
            <td> ${person.userId} </td>
            <td> ${person.userName} </td>
            <td> ${person.password} </td>
            <td> ${person.sex} </td>
            <td> ${person.birthday} </td>
      </tr>
                </c:forEach>
      </table>

输出的结果却是三行重复的内容。请教一下为什么是三个重复的内容呢?list。size()=3,

用户账号   用户名称   密码   性别   生日  
123   123   123   M   2011-08-27   10:29:31.0  
123   123   123   M   2011-08-27   10:29:31.0  
123   123   123   M   2011-08-27   10:29:31.0  

作者: fhlu18   发布时间: 2011-08-27

那就是你本身集合里的数据是重复的:facade.getUserList(parameters); 

作者: tengai_ygj   发布时间: 2011-08-27