如题 extjs代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="../extjs/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css"
href="resources/css/dept.css">
<script type="text/javascript" src="../extjs/ext-all-debug.js"></script>
<!-- <script type="text/javascript" src="../treegrid/app/app.js"></script> -->
<script type="text/javascript">
var store = Ext.create('Ext.data.TreeStore', {
defaultRootId : 'root',
proxy : {
type : 'ajax',
url : 'http://localhost:8080/mvcextjs/treegrid/data/depttree.jsp',
reader : {
type : 'json'
},
writer : {
type : 'json'
}
},
autoLoad : true
});Ext.onReady(function() {
Ext.create('Ext.tree.Panel', {
    title: 'Simple Tree',
    width: 200,
    height: 150,
    store: store,
    rootVisible: false,
    loadMask : false,
    renderTo: Ext.getBody()
    });});
</script>
</head><body>
This is my JSP page.
<br>
</body>
</html>
url 对应的depttree.jsp 代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String depts = "{'success': true,'children': [{ 'id': 1, 'text': 'Phil', 'leaf': true },{ 'id': 2, 'text': 'Nico', 'expanded': true, 'children': [{ 'id': 3, 'text': 'Mitchell', 'leaf': true }]},{ 'id': 4, 'text': 'Sue', 'loaded': true }]}";
 response.getWriter().write(depts); 很简单 就是一个树的json串firebug 已经显示为调用且返回正常,如下图: