Repeats the nested body content of this tag once for every element of the specified collection, which must be an Iterator, a Collection, a Map (whose values are to be iterated over), or an array. The collection to be iterated over must be specified in one of the following ways:As a runtime expression specified as the value of the collection attribute. As a JSP bean specified by the name attribute. As the property, specified by the property, of the JSP bean specified by the name attribute. The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:An array of Java objects or primitives. An implementation of java.util.Collection, including ArrayList and Vector. An implementation of java.util.Enumeration. An implementation of java.util.Iterator. An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap. NOTE - See below for additional information about accessing Maps. Normally, each object exposed by the iterate tag is an element of the underlying collection you are iterating over. However, if you iterate over a Map, the exposed object is of type Map.Entry that has two properties:key - The key under which this item is stored in the underlying Map. value - The value that corresponds to this key. So, if you wish to iterate over the values of a Hashtable, you would implement code like the following:<logic:iterate id="element" name="myhashtable"> Next element is <bean:write name="element" property="value"/> </logic:iterate> If the collection you are iterating over can contain null values, the loop will still be performed but no page scope attribute (named by the id attribute) will be created for that loop iteration. You can use the <logic:present> and <logic:notPresent> tags to test for this case. cookie: The variable to be compared is the value of the cookie whose name is specified by this attribute.(RT EXPR) header: The variable to be compared is the value of the header whose name is specified by this attribute. The name match is performed in a case insensitive manner.(RT EXPR) name: The variable to be compared is the JSP bean specified by this attribute, if property is not specified, or the value of the specified property of this bean, if property is specified.(RT EXPR) parameter: The variable to be compared is the first, or only, value of the request parameter specified by this attribute.(RT EXPR) property: The variable to be compared is the property (of the bean specified by the name attribute) specified by this attribute. The property reference can be simple, nested, or indexed.(RT EXPR) scope: The bean scope within which to search for the bean named by the name property, or "any scope" if not specified.(RT EXPR) value The constant value to which the variable, specified by other attribute(s) of this tag, will be compared.(REQUIRED) (RT EXPR)
request.setAttribute("viewNotCostForm",viewNotCostProcessor.getForm());
的“viewNotCostForm”吗?
request.setAttribute("viewNotCostForm",viewNotCostProcessor.getForm());
的“viewNotCostForm”吗?
是的,心须保持一致。
<logic:iterate id="viewNotCostForm" property="projectList" name="viewNotCostForm" >
如果有子项,只需要改变"property"对应数据映射类的字段。
As a JSP bean specified by the name attribute.
As the property, specified by the property, of the JSP bean specified by the name attribute.
The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:An array of Java objects or primitives.
An implementation of java.util.Collection, including ArrayList and Vector.
An implementation of java.util.Enumeration.
An implementation of java.util.Iterator.
An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap. NOTE - See below for additional information about accessing Maps.
Normally, each object exposed by the iterate tag is an element of the underlying collection you are iterating over. However, if you iterate over a Map, the exposed object is of type Map.Entry that has two properties:key - The key under which this item is stored in the underlying Map.
value - The value that corresponds to this key.
So, if you wish to iterate over the values of a Hashtable, you would implement code like the following:<logic:iterate id="element" name="myhashtable">
Next element is <bean:write name="element" property="value"/>
</logic:iterate>
If the collection you are iterating over can contain null values, the loop will still be performed but no page scope attribute (named by the id attribute) will be created for that loop iteration. You can use the <logic:present> and <logic:notPresent> tags to test for this case.
cookie: The variable to be compared is the value of the cookie whose name is specified by this attribute.(RT EXPR)
header: The variable to be compared is the value of the header whose name is specified by this attribute. The name match is performed in a case insensitive manner.(RT EXPR)
name: The variable to be compared is the JSP bean specified by this attribute, if property is not specified, or the value of the specified property of this bean, if property is specified.(RT EXPR)
parameter: The variable to be compared is the first, or only, value of the request parameter specified by this attribute.(RT EXPR)
property: The variable to be compared is the property (of the bean specified by the name attribute) specified by this attribute. The property reference can be simple, nested, or indexed.(RT EXPR)
scope: The bean scope within which to search for the bean named by the name property, or "any scope" if not specified.(RT EXPR)
value The constant value to which the variable, specified by other attribute(s) of this tag, will be compared.(REQUIRED) (RT EXPR)
即:class StudentList和Student两个类
如果你要显示以下的一个列表:
陈明 2000(3)
李东 2000(4)
你就可以用下面类似的语句:
<logic:iterate id="student" name="studentlist">
<tr>
<td align="left">
<bean:write name="student" property="name" filter="true"/>
</td>
<td align="left">
<bean:write name="student" property="grade" filter="true"/>
</td>
</tr>
</logic:iterate>也就是name中是list对象,id是list里面的各个元素
使用这个id是为了方便下面语句:
<bean:write name="student" property="name" filter="true"/>
的引用
id的取值可以任意,但bean中的name一定要和id一致
name中是list对象,id是list里面的各个元素
你可以在Action中通过
ArrayList result = new ArrayList();
result = getStudent(req); //通过返回结果得出所有学生的值
req.setAttribute("studentlist", result);