html
<form method="get" action="insertSortAction.action">
<table>

<tr id="att"><td><span>属  性:</span></td>名称:<input type="text" name="attrib.key">值<input type="text" name="attrib.value"></td></tr>
 <tr id="att"><td><span>属  性:</span></td>名称:<input type="text" name="attrib.key">值<input type="text" name="attrib.value"></td></tr>


<tr><td><input type="submit" value="提交"></td></tr>
</table>
</form>
Action
public class InsertSortAction extends ActionSupport { private List<Attrib> attrib;}怎样接收页面传来对象,并加到List里
之前用类型转换可以做到,现在想在页面端用attrib.name,attrib.value传,怎么做

解决方案 »

  1.   

    你可以声明一个类,将值放进去,然后将这个类在添加到list里面.还有,你的这个private List<Attrib> attrib;有get\set方法吗?
      

  2.   

    seter geter方法有 没贴出来,别外List指定的泛形类是Attrib 也有对应的Attrib 类
      

  3.   

    用request.getAttribute()或者request.getParameter()获取页面传来的值
      

  4.   

    呵呵,楼主标题有问题哦,类型转换,就是BEAN,和其中的字段值的关系而已吧,
    呵呵,你是将传递回来的值加到list上,????直接add就可以了,
      

  5.   

    我只是想用Struts2的自动转换工能,
    如果Action里:
    private List<Attrib> attrib;
    改为private Attrib attrib;
    名称:<input type="text" name="attrib.name">
    值:<input type="text" name="attrib.value">
    那么Strut2会自动帮name和value设进attrib里,但现在传递的是多个
    名称:<input type="text" name="attrib.name">
    值:<input type="text" name="attrib.value">
    名称:<input type="text" name="attrib.name">
    值:<input type="text" name="attrib.value">
    Action里
    private List<Attrib> attrib;
    attrib没有了name和value页面端还是用对象.属性的写法<input type="text" name="attrib.name">
    类型转换器怎么接收呢我的问题已经解决了,大家可以参考
    http://topic.csdn.net/u/20090808/19/b25926e6-c0ec-4582-96e9-3bf88a7482ed.html