struts2的s:doubleselect 二级菜单没有值

 

二级菜单总是取不到值

public String addNewsPre() throws Exception {
Map<String, List<SmallClass>> map = new LinkedMap();
bigClassList = (ArrayList) ngr.findAllBigClass();
for (int i = 0; i < bigClassList.size(); i++) {
BigClass b = (BigClass) bigClassList.get(i);
smallClassList = ngr.findAllSmallClass(b.getBigClassID());
map.put(b.getBigClassName(),smallClassList);
}
this.setBigClassMap(map);
return SUCCESS;//跳转到下面这个页面
}

<s:form action="addNews.action" name="sdf">
<TABLE width="780" align="center" CELLSPACING=0
background="images/bodybg.jpg">
<s:actionerror />
<s:textfield name="newsTitle" label="标题" />
<s:textarea name="newsContent" label="内容" /> <s:doubleselect list="bigClassList" name="bigClass" 
listKey="bigClassName" listValue="bigClassName" label="请选择大类"
doubleList="bigClassMap[top]" doubleListKey="smallClassName"
doubleName="smallClass" doubleListValue="smallClassName" />

</s:form>

 

 

 

总结一下,结帖

Map<String, List<SmallClass>> map = new LinkedMap();
要改成
Map<Integer, List<SmallClass>> map=new LinkedHashMap();
不然会报上述错误
<s:form action="addNews.action" name="sdf">
要改成
<s:form action="addNews" name="sdf">
不然,二级菜单显示为空


----
public String addNewsPre() throws Exception {
  Map<String, List<SmallClass>> map = new LinkedHashMap();
  bigClassList = (ArrayList) ngr.findAllBigClass();
  for (int i = 0; i < bigClassList.size(); i++) {
  BigClass b = (BigClass) bigClassList.get(i);
  smallClassList = ngr.findAllSmallClass(b.getBigClassID());
  map.put(b.getBigClassID(),smallClassList);
  }
  this.setBigClassMap(map);
  return SUCCESS;
}


<s:form action="addNews" name="sdf">
<s:doubleselect list="bigClassList" name="bigClass" 
listKey="bigClassID" listValue="bigClassName" label="请选择大类"
doubleList="bigClassMap.get(top.bigClassID)" doubleListKey="smallClassName"
doubleName="smallClass" doubleListValue="smallClassName" />

你可能感兴趣的:(exception,struts,String,list,action)