如何显示从struts2使用jsonArray接收的ExtJS树中的数据操作
问题描述:
我是ExtJs的新手,我只是很难读取从struts2应用程序接收到的json数组。如何显示从struts2使用jsonArray接收的ExtJS树中的数据操作
以下是我从Struts应用程序
[{"children":[{"children":[],"cls":"file","id":11,"leaf":true,"text":"A Child 1"},{"children":[],"cls":"file","id":12,"leaf":true,"text":"A Child 2"}],"cls":"folder","id":10,"leaf":false,"text":"A Folder"}]
它工作正常,如果我将它保存在以.json文件,并使用dataUrl把它收到的JSON数组:“json.json”。但是当我使用dataUrl:'myAction.action'调用它时,数据不会被加载。
我真的很感激,如果有人可以对我在这里失踪的东西进行一些洞察。以下是我的.js,这类似于例如通过ExtJS的提供
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
var tree = new Tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'myAction.action',
root: {
nodeType: 'async',
text: 'Ext JS',
draggable: false,
id: 'src'
}
});
// render the tree
tree.render('tree-div');
tree.getRootNode().expand();
});
答
确保您dataUrl
是有效的在运行时。使用FireBug或Safari控制台查看myAction.action
的XHR请求 - 我的猜测是,您可能需要将其更改为/something/myAction.action
。
谢谢朱利安。我很愚蠢,就是这样。我对我的问题提出了完全错误的问题。不过谢谢。 – user270473