日期:2014-05-19 浏览次数:20742 次
public class CategoryAction extends ActionSupport { private List<Category> subcates; //。。。。省略get/set方法 public String getsubcates(){ subcates=categoryManger.getSubCates(pid); return SUCCESS; [color=#FF0000]//注意此处[/color] } }
<package name="json" extends="json-default" > <action name="getsubcatesaction" class="categoryAction" method="getsubcates"> <result name="success" type="json"> <param name="includeProperties"> subcates\[\d+\]\.id,subcates\[\d+\]\.name </param> </result> </action> </package>
function addsubcotes(pid){ alert(pid); ajaxUtil("getsubcatesaction.action?pid="+pid,false,true,null,true, function(data){ alert(data); var jsonObject = eval('(' + data + ')'); var select = document.getElementById("subcate"); select.options.length=0;//清空select alert(jsonObject.subcates); for(var i = 0;i<jsonObject.subcates.length;i++){ var category = list.subcates[i]; slect.add(new Option(category.name,category.id)); } } ); }