类的写法
public String execute() {
comboMeals = new ArrayList<String>();
comboMeals.add("小吃 Plate");
comboMeals.add("正餐 Plate");
comboMeals.add("Colonel Chicken 组合");
comboMeals.add("上校汉堡");
comboMeals.add("O.R. Fillet Burger");
comboMeals.add("Zinger 哈宝");
return SUCCESS;
}
jsp页面的写法
<ol>
<s:iterator value="comboMeals">
<li><s:property /></li>
</s:iterator>
</ol>
<%
List temp = new ArrayList();
temp = (List) request.getAttribute("comboMeals");
out.println(temp);
out.println("<br/>");
%>
6到11行有喜感。
原文:http://www.mkyong.com/struts2/struts-2-iterator-tag-example/
源代码:http://pan.baidu.com/share/link?shareid=470020&uk=3878681452