Jsp 什么是;“地位”;在<;迭代器>;做

Jsp 什么是;“地位”;在<;迭代器>;做,jsp,struts2,iterator,Jsp,Struts2,Iterator,我正在使用以下命令显示“userList”中的值 <s:iterator value="userList" status="rowStatus"> <tr class="even"> <td><s:property value="tweet_id" /></td> <td><s:property value="message" /></td> <td><

我正在使用以下命令显示“userList”中的值

<s:iterator value="userList" status="rowStatus">
  <tr class="even"> 
    <td><s:property value="tweet_id" /></td>
    <td><s:property value="message" /></td>
    <td><s:property value="created" /></td>
  </tr>
</s:iterator>

此命令中的
status=“rowStatus”
有何用途?

来自

迭代器标记可以导出迭代器状态对象,以便 获取有关迭代状态的信息,例如:

index: current iteration index, starts on 0 and increments in one on every iteration
count: iterations so far, starts on 1. count is always index + 1
first: true if index == 0
even: true if (index + 1) % 2 == 0
last: true if current iteration is the last iteration
odd: true if (index + 1) % 2 == 1
范例

   <s:iterator status="rowStatus" value='{0, 1}'>
      Index: <s:property value="%{#rowStatus.index}" /> <br />
      Count: <s:property value="%{#rowStatus.count}" /> <br />  
   </s:iterator>
在您的用户列表中

userList count = 1 to userList.size();
userList index = 0 to userList.size() - 1;

迭代器标记可以导出迭代器状态对象,以便 获取有关迭代状态的信息,例如:

index: current iteration index, starts on 0 and increments in one on every iteration
count: iterations so far, starts on 1. count is always index + 1
first: true if index == 0
even: true if (index + 1) % 2 == 0
last: true if current iteration is the last iteration
odd: true if (index + 1) % 2 == 1
范例

   <s:iterator status="rowStatus" value='{0, 1}'>
      Index: <s:property value="%{#rowStatus.index}" /> <br />
      Count: <s:property value="%{#rowStatus.count}" /> <br />  
   </s:iterator>
在您的用户列表中

userList count = 1 to userList.size();
userList index = 0 to userList.size() - 1;
就你而言,没有

迭代时,当前对象被推到值堆栈的顶部。这意味着您只需使用它的名称(以及)即可访问它

对于
属性,可以根据需要使用此值

但是,如果(在与您不同的情况下,但您肯定很快会遇到)您需要将此值放入表单字段,该字段将提交回(其他)操作,目标是
列表
属性,那么您需要使用迭代器状态装载正确的
名称
属性。例如:

SourceAction

private List<User> sourceUserList; 
私有列表sourceUserList;
目标

private List<User> updatedUserList; 
私有列表更新服务列表;
JSP


明白了吗?

在你的情况下,没有

迭代时,当前对象被推到值堆栈的顶部。这意味着您只需使用它的名称(以及)即可访问它

对于
属性,可以根据需要使用此值

但是,如果(在与您不同的情况下,但您肯定很快会遇到)您需要将此值放入表单字段,该字段将提交回(其他)操作,目标是
列表
属性,那么您需要使用迭代器状态装载正确的
名称
属性。例如:

SourceAction

private List<User> sourceUserList; 
私有列表sourceUserList;
目标

private List<User> updatedUserList; 
私有列表更新服务列表;
JSP


明白了吗