ajax做json拼接
来源:互联网 发布:fast paxos java示例 编辑:程序博客网 时间:2024/05/27 16:41
{
"id": "100000",
"menu": [
{
"text": "部门管理",
"items": [
{
"id": "100006",
"text": "部门增加",
"href": "http://localhost:8080/RBAC/Department/Department_add.jsp"
},
{
"id": "100007",
"text": "部门维护",
"href": "http://localhost:8080/RBAC/selectDepartment"
}
]
}
]
},
{
"id": "100001",
"menu": [
{
"text": "用户管理",
"items": [
{
"id": "100008",
"text": "用户增加",
"href": "http://localhost:8080/RBAC/getDeptNameList"
},
{
"id": "100009",
"text": "用户维护",
"href": "http://localhost:8080/RBAC/selectUser"
}
]
}
]
},
{
"id": "100002",
"menu": [
{
"text": "角色管理",
"items": [
{
"id": "100010",
"text": "角色增加",
"href": "http://localhost:8080/RBAC/Role/role_add.jsp"
},
{
"id": "100011",
"text": "角色维护",
"href": "http://localhost:8080/RBAC/selectRole"
}
]
}
]
},
{
"id": "100003",
"menu": [
{
"text": "菜单管理",
"items": [
{
"id": "100012",
"text": "菜单增加",
"href": "http://localhost:8080/RBAC/selectFatherMenu"
},
{
"id": "100013",
"text": "菜单维护",
"href": "http://localhost:8080/RBAC/selectMenu"
}
]
}
]
},
{
"id": "100004",
"menu": [
{
"text": "角色人员管理",
"items": [
{
"id": "100014",
"text": "角色人员维护",
"href": "http://localhost:8080/RBAC/selectRoleUser"
}
]
}
]
},
{
"id": "100005",
"menu": [
{
"text": "权限管理",
"items": [
{
"id": "100015",
"text": "用户权限设置",
"href": "http://localhost:8080/RBAC/selectUserMenu"
},
{
"id": "100016",
"text": "部门权限设置",
"href": "http://localhost:8080/RBAC/selectDeptMenu"
},
{
"id": "100017",
"text": "角色权限设置",
"href": "http://localhost:8080/RBAC/selectRoleMenu"
}
]
}
]
}
]
在action
//处理一个ajax请求
public void child(){
String st = ser.child();
//异步传值
HttpServletResponse res=ServletActionContext.getResponse();
res.setContentType("text/html;charset=utf-8");
try {
PrintWriter pw=res.getWriter();
pw.print(st);
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
对这个文档做拼接在业务处理层
public String child() {
List<TtMenu> menulist=dao.find("from TtMenu where fatherMenuId=1");
JSONArray all = new JSONArray();
JSONObject first_menu = new JSONObject();
for(TtMenu mn:menulist){//一级菜单
first_menu.put("id", mn.getMenuId());
//拼一级菜单
JSONArray first_arr = new JSONArray();
//只放一个json(一级菜单)对象,包含二级菜单
JSONObject first= new JSONObject();
first.put("text", mn.getMenuName());
JSONArray second_arr = new JSONArray();
//拼二级菜单
JSONObject second= new JSONObject();
for(TtMenu m:mn.getChildMenu()){//二级菜单
second.put("id",m.getMenuId() );
second.put("text", m.getMenuName());
second.put("href", m.getMenuValue());
second_arr.add(second);
}
first.put("items", second_arr);
first_arr.add(first);
first_menu.put("menu", first_arr);
all.add(first_menu);
}
return all.toString();
}
- ajax做json拼接
- jquery拼接ajax 的json和字符串拼接
- Jquery Ajax返回Json字符串 拼接table
- ajax请求后返回多个json数组,后台拼接
- mysql+php+ajax实现分页查询(JSON拼接)
- JSON拼接
- ajax+json 做数据异步交互
- Ajax(5):利用json做数据交换
- ajax获取数据,应该返回json用js拼接 还是在后台拼接HTML完再返回
- java 拼接子串的方式做字符串替换生成json
- 前台用的是ajax请求,后台json字符串拼接方式
- 二维数组转为json后,ajax这边拼接成表格 要循环??具体怎么写了 ,,
- AJAX提交到Handler.ashx一般处理程序返回json数据 (字符串拼接方式)
- 拼接json和解析json
- 拼接JSON字符串对象
- json手动拼接
- json拼接一种方法
- 拼接json字符串
- axis2的使用(转载)
- Java中Volatile变量小结
- 20191021考试总结2
- 模板模式 template
- CCF CSP Markdown JAVA 201703-3
- ajax做json拼接
- Restricted Boltzmann Machine(限制玻尔兹曼机)
- hdu5512
- 【MySQL】MySQL客户端实现
- hive学习笔记-hive的基本语法
- mycelipse 按ctrl 死机问题
- DBCP连接池使用方法
- 愚人节的礼物 c语言实现
- 一篇文章看懂select_poll_epoll