Ajax加载Ztree数据显示不到页面

公子七 2016-06-11 03:54:48
package cn.itcast.oa0909.struts2.action;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.json.annotations.JSON;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.oa0909.domain.Menuitem;
import cn.itcast.oa0909.service.MenuitemService;
import cn.itcast.oa0909.struts2.action.base.BaseAction;

@Controller("menuitemAction")
@Scope("prototype")
public class MenuitemAction extends BaseAction<Menuitem>{
@Resource(name="menuitemService")
private MenuitemService menuitemService;

private Collection<Menuitem> menuitemList;


public Collection<Menuitem> getMenuitemList() {
return menuitemList;
}


@JSON(serialize=false)
public String getAllMenuitem(){
this.menuitemList = this.menuitemService.getAllMenuitem();
return SUCCESS;
}
}

==============
var tree = {

setting:{ isSimpleData: true, treeNodeKey: "mid", treeNodeParentKey:
"pid", showLine: true, root:{ isRoot:true, nodes:[0] } },

/**
* 1、回调函数是由服务器端触发的,什么时候执行由服务器决定 2、回调函数是由jQuery内核调用的 3、客户端存在两个线程
* 4、如果在js代码中,有一些代码要用到回调函数中的数据,那么这些代码必须放在回调函数中
*/
loadTree : function() {
// 发送请求
$.post("menuitemAction_getAllMenuitem.action", null, function(data) {
alert(data.menuitemList);
/* $("#tree").zTree(tree.setting,data.menuitemList); */
});
}
};
$().ready(function() {
tree.loadTree();
});
...全文
411 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
clever101 2017-10-11
  • 打赏
  • 举报
回复
请问楼主是怎么解决的呢?
公子七 2016-06-28
  • 打赏
  • 举报
回复
谢谢各位。问题已经解决了
菜 头 2016-06-27
  • 打赏
  • 举报
回复
先检查下json数据出来没,再检查Ztree是否配对
lwp_trouble 2016-06-25
  • 打赏
  • 举报
回复
你应该先访问返回json的controller有没有你要的值。。
河岸飞流 2016-06-23
  • 打赏
  • 举报
回复
请求有没有到后台?感觉更多可能是树没有定义好,ztree的api应该很详细啊,参照demo就行了,这是我之前弄的一个http://www.cnblogs.com/xieshuang/p/5359034.html 你参考一下
公子七 2016-06-11
  • 打赏
  • 举报
回复
这是这是出错的提示
公子七 2016-06-11
  • 打赏
  • 举报
回复
后台的数据不能加载到Ztree上,求大神帮忙解决下 这个是我的页面<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>tree.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <script src="js/jquery-1.4.2.js"></script> <script src="js/jquery-ztree-2.5.js"></script> <link rel="stylesheet" type="text/css" href="zTreeStyle/zTreeStyle.css"> <script src="js/tree.js"></script> <body> This is not my HTML page. <br> <div> <ul id="tree" class="tree" style="width:230px; overflow:auto;"></ul> </div> </body> </html>

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧