一个主类型Catalog,还有子类型Subcatalog,一对多关系,现在要找出所有的类型,用s:doubleselec表示出来
Subcatalog表里有catalogid列对应Catalog表中的catalogid列.jsp里的代码,有问题:只找出主类型,没有找出子类型: <body>
<s:form action="rsseditsave" namespace="/admin"> <s:form action="Store">
<s:doubleselect list="catalogmap.keySet()"
doubleName="subcatalogname" doubleList="catalogmap.list.subcatalogname[top]"
label="类型" theme="css_xhtml" />
</s:form>
</s:form> </body>
action里的代码是正确的: public String rssedit() throws Exception {
Map map = new LinkedMap();
cataloglist = (ArrayList) catalogService.findAll();
for (int i = 0; i < cataloglist.size(); i++) {
Catalog c = (Catalog) cataloglist.get(i);
List list = subcatalogService
.find("from Subcatalog where catalogid=" + c.getCatalogid());
SubcatList sl=new SubcatList();
map.put(c.getCatalogname(), list);
}
this.setCatalogmap(map);
return SUCCESS;
}

解决方案 »

  1.   

    改正:
    action里的代码: public String rssedit() throws Exception {
    Map map = new LinkedMap();
    cataloglist = (ArrayList) catalogService.findAll();
    for (int i = 0; i < cataloglist.size(); i++) {
    Catalog c = (Catalog) cataloglist.get(i);
    List list = subcatalogService
    .find("select subcatalogname,subcatalogid from Subcatalog where catalogid=" + c.getCatalogid());
    map.put(c.getCatalogname(), list);
    }
    this.setCatalogmap(map);
    return SUCCESS;
    }
    .jsp里的代码:
    <s:form action="Store">
    <s:doubleselect list="catalogmap.keySet()"
    doubleName="subcatalogname" doubleList="catalogmap.subcatalogname" doubleListKey="catalogmap.subcatalogid"
    label="类型" theme="css_xhtml" />
    </s:form>
    怎么在s:doubleselect里获得map的值???
      

  2.   

    看看这篇文章 http://www.360doc.com/content/08/1123/12/61497_1984159.shtml
    指定list listkey listvalue及相应的double的,doublelise要根据对应的上层的key去取。
      

  3.   

    aciton
    private List<EquipmentRoomInfo> equipmentRoomList = new ArrayList<EquipmentRoomInfo>();
    private Map<EquipmentRoomInfo, List<CabinetsInfo>> cabinetsMap = new HashMap<EquipmentRoomInfo, List<CabinetsInfo>>();jsp
    <s:doubleselect theme="simple" list="equipmentRoomList" listValue="equipmentRoomName" name="equipmentRoomId" listKey="equipmentRoomId" doubleList="cabinetsMap.get(top)" 
      doubleName="cabinetsId"  doubleListKey="cabinetsId" doubleListValue="cabinetsNum" formName="inputForm"/>
      

  4.   

    struts真难学,我大概试了一百多次才成功
    public String rssedit() throws Exception {
    Map<String, List<Subcatalog>> map = new LinkedMap();
    cataloglist = (ArrayList) catalogService.findAll();
    for (int i = 0; i < cataloglist.size(); i++) {
    Catalog c = (Catalog) cataloglist.get(i);
    List<Subcatalog> list = subcatalogService
    .find("from Subcatalog where catalogid=" + c.getCatalogid());
    map.put(c.getCatalogname(), list);
    }
    this.setCatalogmap(map);
    return SUCCESS;
    }jsp的代码:
    <s:form action="rsseditsave" namespace="/admin">
    <s:doubleselect  list="catalogmap.keySet()" name="test"
    doubleName="subcatalogname" doubleList="catalogmap[top]" 
    doubleListValue="subcatalogname" 
     label="类型" />
    </s:form>
    结贴