google半天了,没有这个类型的
谢谢了
[b]问题补充:[/b]
能不能给个简单的模型,我这实在调不同了
谢谢
不好意思,最后的代码,没有设置好,应该是:
[code="jsp"]
Key :
Value :
/s:iterator
/s:iterator[/code]
[color=red]通过以上方法,即可把你的类型是list>的变量userList中的东西都依次显示在页面中。[/color]
[quote]list>
没有这个类型的 [/quote]
什么就没有这个类型。。
这里应该是个list +泛型(这里用了map);
这里list容器里面,是个map
而map 里的key value 是两个String
其实你可以去看看java 基础 看看什么是泛型
[url]http://luofeng113.iteye.com/blog/219383[/url]
[url]http://jnotnull.iteye.com/blog/201444[/url]
泛型啊
[code="java"]
List> listMap = new ArrayList>();
[/code]
如果你的Action中有一个这样类型的变量,并提供了set和get方法,如下:
[code="java"]private List> userList;
public List<Map<String, String>> getUserList() {
return userList;
}
public void setUserList(List<Map<String, String>> userList) {
this.userList = userList;
}[/code]
在你Action中为该变量赋值:如下:
[code="java"]public String execute() {
userList = new ArrayList>();
Map map = new HashMap();
map.put("1", "value1");
map.put("2", "value2");
map.put("3", "value3");
userList.add(map);
setUserList(userList);
return SUCCESS;
}[/code]
然后在你的成功页面中,要想遍历list>,即你Action中的userList。可以这样写:
[code="jsp"]
Key :
Value :
/s:iterator
通过以上方法,即可把你的类型是list>的变量userList中的东西都依次显示在页面中。
/s:iterator[/code]
[code="xml"]
Key :
Value :
/s:iterator
/s:iterator
[/code]
用双重循环就可以了
四楼贴的代码很详细,就是一个嵌套循环,struts2的迭代标签跟java的循环很像了,多试试啥问题都可以解决了