只能获取value,就是一个普通表单,普通jsp/servlet获取表单中的select也是获取的value呀不知道我理解没理解你的意思
list<object>的获取方式,可以用struts2默认的转换器获取,提交的时候用js把select的内容全部选中,这样select的value全部回传到后台的list<object>属性中
一般s:select一般不从界面获取,都是在后台获取,提交的时候,在action中重新重数据库中查出来

解决方案 »

  1.   

    这个应该可以,比在List中查找来的可靠!
    -----------------------------------------------
    补充问题:struts2能否生成动态表单,如何获取动态表单的值?
    动态表单是指和"s2的文件上传表单"一样,页面上面可以有多个<s:file name='名称都相同'>,action中用数组获取!
    <s:select>可以用数组获取多个表单吗?
    谢谢!
      

  2.   

    struts2支持动态表单,举个例子,这里可用迭代器来循环
    <s:textfield theme="simple" name="persons[0].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[0].personCode"></s:textfield><s:textfield theme="simple" name="persons[1].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[1].personCode"></s:textfield><s:textfield theme="simple" name="persons[2].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[2].personCode"></s:textfield>
    ......
    后台
    private List<Person> persons;//三条person,对应页面的code和name等。可以是对象数组
    struts2提供了默认实现,无需配置类转换器
      

  3.   

    struts1.x里面有optionsCollection这个标签
    就是迭代的struts不太清楚,你可以找找看
      

  4.   

    对action里面的model数据的属性赋值,url参数形式是不是这样的:
    www.url.com?model.id="值"&model.key="值"                 这个是对象
    www.url.com?array[1].id="值"&array[1].key="值"           这个是数组对应的action中的属性为public class myAction{
    private Model model;
    private Array array[];
    }其中属性类Model为pojo:
    class model{
    private String key;
    private String id;
    }不过我这样的url访问action的属性,没有反应,呵呵?奇怪
      

  5.   

    struts2可以得到request,换句话,你想干什么都可以
      

  6.   

    用list吧,我测试了一下数组,似乎有问题,这个可能要用struts2的类转换器来做,麻烦点。而且我认为list更胜任这个任务
    public class myAction{
    private Model model;
    private List<Model> list;
    }
    www.url.com?model.id="值"&model.key="值"                这个是对象
    www.url.com?list[0].id="值"&list[0].key="值"          这个是数组 
      

  7.   

    List <Model> list我测试也有问题的,呵呵?
    你对List做测试啦? success?
      

  8.   

    当然做过了,而却用过很多次,list绝对没问题的,否则我在这乱说什么,找打呢,呵呵
    我的struts版本是2.0.11.1记得我以前回答过别人这个问题,自从jdk5出来之后,简单的集合对象的映射,不用配置ClassName-conversion.properties,因为有了泛型List <Model>,你自己好好检查检查吧!
      

  9.   

    <s:textfield theme="simple" name="persons[0].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[0].personCode"></s:textfield><s:textfield theme="simple" name="persons[1].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[1].personCode"></s:textfield><s:textfield theme="simple" name="persons[2].personID"></s:textfield>---------<s:textfield theme="simple" name="persons[2].personCode"></s:textfield>