迭带的方式都一样不过你写的好象不太对劲啊
我写了个例子 你看看吧TestViewObject.javapublic class TestViewObject {
private String userOne;
private String userTwo;
private String userThree; public String getUserOne() {
return userOne;
} public void setUserOne(String userOne) {
this.userOne = userOne;
} public String getUserTwo() {
return userTwo;
} public void setUserTwo(String userTwo) {
this.userTwo = userTwo;
} public String getUserThree() {
return userThree;
} public void setUserThree(String userThree) {
this.userThree = userThree;
}
}TestAction.java
import java.util.ArrayList;
import java.util.List;import struts.vo.TestViewObject;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport {
/**
 * 
 */
private static final long serialVersionUID = 1L;
private TestViewObject vo;
List<TestViewObject> list; public TestViewObject getVo() {
return vo;
} public void setVo(TestViewObject vo) {
this.vo = vo;
} public List<TestViewObject> getList() {
return list;
} public String execute() throws Exception {
TestViewObject vo;
list = new ArrayList<TestViewObject>();
for (int i = 0; i < 3; i++) {
vo = new TestViewObject();
vo.setUserOne(i + " gaga");
vo.setUserTwo(i + " dudu");
vo.setUserThree(i + " haha");
list.add(vo);
}
return "success";
}
}
struts.xml<?xml version="1.0" encoding="GBK" ?>
<!--指定struts2配置文件的DTD信息-->
<!DOCTYPE struts PUBLIC 
 "-//apache Software Foundation//DTD Struts Configuation 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- struts 是struts2配置文件的根元素-->
<struts>
<include file="struts-default.xml"></include>
<!--struts2的Action必须放在指定的包空间下定义-->
<package name="test" extends="struts-default">
<action name="testAction" class="TestAction">
<result>/success.jsp</result>
</action>
</package>
</struts> 
success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<s:iterator value="list">
<s:property value="userOne" />
<s:property value="userTwo" />
</s:iterator>
</body>
</html>

解决方案 »

  1.   

    我的Action里有:    public List<TestViewObject> getList() {
            return list;
        }
    JSP页面通过这个方法获得list属性 页面迭代的时候
     
       <s:property value="userOne" />
       <s:property value="userTwo" />
    他会自动寻找迭代对象里的属性
        private String userOne;
        private String userTwo;大家都是刚学STRUTS2 互相帮助 ~~
      

  2.   

    我的Action里有:    public List<TestViewObject> getList() {
            return list;
        }
    JSP页面通过这个方法获得list属性 页面迭代的时候
     
       <s:property value="userOne" />
       <s:property value="userTwo" />
    他会自动寻找迭代对象里的属性
        private String userOne;
        private String userTwo;大家都是刚学STRUTS2 互相帮助 ~~
      

  3.   

    回楼上,你写的是对list的迭代吧,我需要的是对map的迭代,不过还是谢谢你啊
      

  4.   

    <s:iterator value="map.keySet()" id="bookId"> 
    <tr> 
    <td> 
    <s:property value="map.get(#bookId)"/> 
    </td> 
    </tr> 
    </s:iterator>
      

  5.   

    我也没实验过用MAP 不过 你试试用s:append 我想可以办到的
      

  6.   

    主要是map的key是个bean,如果是string或者int的话就好办了
      

  7.   

    找到问题了,我数据放在session里的,用#map取不到,真晕,我那写法是可以的