xindongyinfu
2010-06-30 10:05 阅读 157

Ext服务器交互问题

js:
[code="java"]
Ext.onReady(function() {
var store = new Ext.data.JsonStore({
url : "student.ejf",
root : "result",
fields : ["id", "name", "sex", "email", {
name : "bornDate",
type : "date",
dateFormat : "Y-n-j"
}]
});
var colM = new Ext.grid.ColumnModel([{
header : "姓名",
dataIndex : "name",
sortable : true
},{
header : "性别",
dataIndex : "organization"
},{
header : "出生日期",
dataIndex : "bornDate",
width : 120
},{
header : "电子邮件",
dataIndex : "email",
sortable : true
}]);
var grid = new Ext.grid.EditorGridPanel({
renderTo : "hello1",
title : "学生基本信息管理",
height : 200,
width : 600,
cm : colM,
store : store,
autoExpandColumn : 3,
clicksToEdit : 1
});
});
[/code]
java:
[code="java"]
protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
doPost(arg0,arg1);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("out============");
String json = "{results:[{id:1,name:'小王',email:'xiaowang@easyjf.com',sex:'男',bornDate:'1991-4-4'},{id:2,name:'小李',"+
"email:'xiaoli@easyjf.com',sex:'男',bornDate:'1992-5-6'},{id:3,name:'小兰',email:'xiaoxiao@easyjf.com',sex:'女',bornDate:'1993-3-7'}]}";
PrintWriter out = response.getWriter();
out.print(json);
out.close();
}
[/code]
Web.xml:
[code="java"]<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


action
cn.com.ext.ExtDemo2


action
*.ejf

[/code]
为何去不到数据?貌似根本就没有提交?初学ext,不懂为啥?还有json的数据可以这么写吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    noriri noriri 2010-06-30 10:48

    那是请求地址。。你要store.load()下

    点赞 评论 复制链接分享
  • noriri noriri 2010-06-30 10:15

    store都没装载数据。。怎么会有数据么

    点赞 评论 复制链接分享
  • noriri noriri 2010-07-01 07:56

    网页开头设置个UTF-8么。

    点赞 评论 复制链接分享

相关推荐