什么是“状态” in< s:iterator>做? [英] What does "status" in <s:iterator> do?

查看:130
本文介绍了什么是“状态” in< s:iterator>做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令显示'userList'中的值

I am using the following command to display values from '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有什么用?在这个命令中?

推荐答案

在你的情况下,没有。

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

When iterating, the current object is pushed on top of the Value Stack. This means you can access it by simply using its name (along with the many other ways).

您可以根据需要使用此值属性。

You can use this value as you wish for the value attribute.

但是如果(在不同于您的情况下,但您很快就会遇到),则需要将此值放在表单字段中,该字段将提交回(其他)操作,目标是 List< YourObject> 属性,然后您需要使用IteratorStatus来挂载正确的名称属性。例如:

But if (in a case different from your, but that you will certainly encounter soon) you need to put this value in a form field that will be submitted back to an(other) Action, targeting a List<YourObject> attribute, then you need to use IteratorStatus to mount the correct name attribute. For example:

SourceAction

SourceAction

private List<User> sourceUserList; 

TargetAction

TargetAction

private List<User> updatedUserList; 

JSP

<s:form action="targetAction">
  <s:iterator value="sourceUserList" status="rowStatus">

    <s:hidden name="updatedUserList[%{#rowStatus.index}].id" value="id"/>
    <s:property value="id" />

    <s:textfield name="updatedUserList[%{#rowStatus.index}].name" value="name" />
    <s:textfield name="updatedUserList[%{#rowStatus.index}].age"  value="age"  />

  </s:iterator>
  <s:submit/>
</s:form>

知道了吗?

这篇关于什么是“状态” in&lt; s:iterator&gt;做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆