使用代理从我的Web服务获取数据:Sencha Touch 2的Rest

使用代理从我的Web服务获取数据:Sencha Touch 2的Rest,rest,sencha-touch-2,Rest,Sencha Touch 2,使用此代码时,我无法获得任何结果 Ext.define('Teste.view.Main', { extend: 'Ext.Container', initialize: function(){ Ext.define('User', { extend: 'Ext.data.Model', config: { fields: ['description', 'discountCode' , 'prodCode'],

使用此代码时,我无法获得任何结果

Ext.define('Teste.view.Main', {
extend: 'Ext.Container',
initialize: function(){    
    Ext.define('User', {
        extend: 'Ext.data.Model', 
       config: {  
            fields: ['description', 'discountCode' , 'prodCode'],
            proxy: {
                type: 'rest',
                format:'json',
                url : 'http://localhost:8080/stcws/resources/com.database.productcode/'
            }     
        }    
    });     
    var store = new Ext.create('Ext.data.Store', {     
        model: 'User'  
    }); 
    store.load();
    console.log(store.getCount());   
}});
但是如果我拿出去

format:'json',

我得到一个XML响应,我做错了什么?

使用Json阅读器读取服务器响应

试试看:

proxy: {
        type: 'ajax',
        url : 'users.json',
        reader: {
            type: 'json'
        }
    }


要使用“Rest”代理并获得Json响应,我们只需要添加到代理中:

headers: {                
    'Accept' : 'application/json'                 
},
然后拿出

format:'json',

我得到了它!我们只需要添加到代理中<代码>标题:{'Accept':'application/json'}。
format:'json',