首页 > 代码库 > Struts2标签遍历List<Map<String, String>>

Struts2标签遍历List<Map<String, String>>

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

	private List<Map<String, String>> list;

	@Override
	public String execute() {
		list = new ArrayList<Map<String, String>>();

		Map<String, String> map = new HashMap<String, String>();
		map.put("name", "zhangsan");
		map.put("sex", "boy");
		map.put("age", "25");

		list.add(map);

		return "success";
	}

	public List<Map<String, String>> getList() {
		return list;
	}

	public void setList(List<Map<String, String>> list) {
		this.list = list;
	}

}

jsp中使用s:iteraotr标签遍历List

<s:iterator id="map" value=http://www.mamicode.com/"list" status="state">>

输出如图:

技术分享

Struts2标签遍历List<Map<String, String>>