Recently do graduation design used to Struts2 tag library, encountered some more complex data display, the individual or more like to use tag display, Struts2 tags content is rich, but the documentation provided is not very detailed (personally think) under the showcase examples such as: <s: The Select/><s:doubleselect/><s:updownselect/><s:optiontransferselect/> Are some simple value displays, In the actual development is not so simple, if we want to iterate to show the list, Map, set values, what do we do?
Look at the examples in HTML,
<select name="sex">
<option value="man">男 </option>
<option value="women">女</option>
</select>
Sex indicates that the submitted name,man/women is the value represented by the corresponding page display, and that the male/female is the final value for the page.
And what do we do if we want to display the data in a list collection?
Look at the following JSP page:
<select name="department">
<%
Department department = null;
List list = (List) request.getAttribute("list");
Iterator iter = list.iterator();
while (iter.hasNext()) {
department = (Department) iter.next();
%>
<option value="<%=department.getDep_name() % >"><%=department.getDep_name()% > </option>
<%
}
%>
</select>
The iteration is Department's property Dep_name, which appears cumbersome, if the iterator output might be better, with JSTL output:
<c:forEach var="department" items="" varStatus="status">
<tr>
<td>${status.dep_name }</td>
<td>${status.dep_id }</td>
<td>......</td>
</tr>
</c:forEach>