struts中for循环遍历

来源:互联网 发布:stc51单片机和mcs 编辑:程序博客网 时间:2024/05/24 01:49

<s:form action="" theme="simple" name="right">
    <table border="1" width="50%">
     <tr>
      <td colspan="2" align="center">基础信息</td>
     </tr>
     <s:iterator value="userList" id="user">
      <tr>
       <td><s:property value="#user.merName"/></td>
       <td><s:property value="#user.merPay"/></td>
      </tr>
     </s:iterator>
    </table>

</s:form>

ps:

userList是Action中的集合,user是集合中对象的别名

其实就类似于java里的foreach循环
for(User user:UserList){
 sysout(user.getMerName());//简写输出语句
}