JS代码
(function(){
.post("getItemCatList.action",null,function(data){ var str="";
.each(data,function(index,info)str+=""+info[′name′]+"";)
("#c1").append(str); })
("#c1").change(function(){
$("#c2").empty();
$.post("getItemCatList.action",{parentId:$(this).val()},function(data){
var str="";
$.each(data,function(index,info){
str+=""+info['name']+"";
})
$("#c2").append(str);
})
})
("#c2").change(function(){
("#c3").empty();
.post("getItemCatList.action",{parentId:
(this).val()},function(data){
var str="";
.each(data,function(index,info){ str+=""+info['name']+""; }) $("#c3").append(str); }) }) })
一级菜单
未选择
二级菜单
未选择
三级菜单
未选择
Java代码
@Autowired
private ItemCatService itemCatService;
@RequestMapping("getItemCatList")
@ResponseBody
public List<TbItemCat> getItemCatList(@RequestParam(value = "parentId", defaultValue = "0") long parentId) {
return itemCatService.getByParentId(parentId);
}
表: