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.持续更新