easyui树形菜单制作之二级目录实现

6 篇文章 0 订阅
6 篇文章 0 订阅

1.参考

参考该博客

2.后台daoimpl无修改,有需要看前面的博客

3.action类(稍大程度的修改)

/**
 * 
 */
package com.jit.z2206.sue.md5webproject.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jit.z2206.sue.md5webproject.model.Menu;
import com.jit.z2206.sue.md5webproject.service.MenuService;
import com.opensymphony.xwork2.ActionSupport;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author sue wong
 * 2017年7月26日上午9:15:46
 * since v1.0
 */
public class MenuAction extends ActionSupport{
	private JSONArray json;
	private MenuService menuservice;
	private Menu menu;
	private List<Menu> list;
	private JSONObject obj;
	private JSONArray child;
	
	


	/**
	 * @return the child
	 */
	public JSONArray getChild() {
		return child;
	}


	/**
	 * @param child the child to set
	 */
	public void setChild(JSONArray child) {
		this.child = child;
	}


	/**
	 * @return the obj
	 */
	public JSONObject getObj() {
		return obj;
	}


	/**
	 * @param obj the obj to set
	 */
	public void setObj(JSONObject obj) {
		this.obj = obj;
	}


	/**
	 * @return the menu
	 */
	public Menu getMenu() {
		return menu;
	}


	/**
	 * @param menu the menu to set
	 */
	public void setMenu(Menu menu) {
		this.menu = menu;
	}


	

	/**
	 * @return the json
	 */
	public JSONArray getJson() {
		return json;
	}


	/**
	 * @param json the json to set
	 */
	public void setJson(JSONArray json) {
		this.json = json;
	}


	/**
	 * @return the menuservice
	 */
	public MenuService getMenuservice() {
		return menuservice;
	}


	/**
	 * @param menuservice the menuservice to set
	 */
	public void setMenuservice(MenuService menuservice) {
		this.menuservice = menuservice;
	}


	public String execute()throws Exception{
		JSONArray childMenu = new JSONArray();
		
	
		if(menu.getId()==null){
		menu.setId(0);
		}
		list=menuservice.findMenu(menu);
		
		json=JSONArray.fromObject(list);
	
		
		for(Menu m:list){
			JSONObject jsonMenu=JSONObject.fromObject(m);
			
			//System.out.println(m.getTid());
			List<Menu> l=menuservice.findMenu(m);
			
			JSONArray array=JSONArray.fromObject(l);
			
		
			jsonMenu.put("children", array);
			childMenu.add(jsonMenu);
		
			
		}
		
		child=childMenu;
		System.out.println(child.toString());
		/*Map<String,Object> map=new HashMap<String,Object>();
		map.put("total", json.size());
		map.put("rows",json);
		obj=JSONObject.fromObject(map);
		System.out.println(obj);*/
		return "success";
		
	}

}

4.前台无修改

5.数据库


6.效果图


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值