easyui树形菜单学习第一步

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

1.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;
	
	
	/**
	 * @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{
		System.out.println("sssssssssssssssssssssssss");
		
		list=menuservice.findMenu(menu);
		
		json=JSONArray.fromObject(list);
		System.out.println(json);
		System.out.println("ssssssssssssss");
		/*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";
		
	}

}
2.Struts代码

<package name="jsontest" extends="json-default" namespace="/">
		<action name="menuaction"
			class="com.jit.z2206.sue.md5webproject.action.MenuAction">
			<result name="success" type="json">
				<param name="root">json</param>
			</result>
		</action>
	</package>

3.jsp代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css"
          href="jquery-easyui-1.3.6/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css"
          href="jquery-easyui-1.3.6/themes/icon.css">
    <link rel="stylesheet" type="text/css"
          href="jquery-easyui-1.3.6/demo/demo.css">
    <script type="text/javascript" src="jquery-easyui-1.3.6/jquery.min.js"></script>
    <script type="text/javascript"
            src="jquery-easyui-1.3.6/jquery.easyui.min.js"></script>
    <title>jQuery EasyUI</title>


    <script type="text/javascript">
        /*$('#tt').tree({

            animate:true,

        });*/
        $(function(){
  
        	
        	
        	
        	
        	
        	
            $('#box').tree({
 	           
            	
		   			
		   			url:"menuaction"
		   			
				
             });
            
        });


    </script>
</head>
<body>
<h1>Tree</h1>

<ul id="box" class="easyui-tree"></ul>



</body>
</html>

4.数据库

5.效果图


6.持续更新

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值