2016-05-31 66 views
-1

我每次嘗試加載我的商店時都會收到內部服務器500錯誤。我目前正試圖連接到包含我需要的數據的API端點。這是我得到的每一次錯誤(僅供參考,檢查「接受」標題,似乎它是空的,我不知道我怎麼能有一個application/json沒有正確連接到它。):ExtJS 4.2 - 內部服務器錯誤500當加載存儲

enter image description here

我的店是設置這樣的:

Ext.define('EcommBackoffice.store.TierCapacity', { 
    extend: 'Ext.data.Store', 
    model: 'EcommBackoffice.model.TierCapacityModel', 
    storeId: 'tier-capacity-id', 
    autoLoad: true, 
    sorters: [{ 
    property: 'name', 
    direction: 'ASC' 
    }], 
    proxy: { 
    type: 'rest', 
    url: EcommBackoffice.Global.getAPIEndPoints().tier_capacity + '?siteCode=bgp88', 
    reader: { 
     type: 'json', 
     root: '' 
    }, 
    listeners: { 
     exception: function(proxy, response, op) { 
     if (response.status === 403 || response.status === 401) return; /*skip this exception handler and check App exception handler*/ 
     Ext.Msg.alert('ERROR', response.responseText + ' ' + response.statusText); 
     } 
    } 
    } 
}); 

我的模式是這樣的:

Ext.define('EcommBackoffice.model.TierCapacityModel', { 
    extend: 'Ext.data.Model', 
    fields: [{ 
    name: 'id' 
    }, { 
    name: 'paymentOption', 
    type: Ext.data.SortTypes.asUCString 
    }, { 
    name: 'tier', 
    type: Ext.data.SortTypes.asUCString 
    }, { 
    name: 'media', 
    type: Ext.data.SortTypes.asUCString 
    }, { 
    name: 'channels', 
    type: Ext.data.SortTypes.asUCString 
    }] 
}); 

的API包含了這樣的事情:

[{ 
    "name": "DEBIT", 
    "tiers": [{ 
     "name": "Default", 
     "media": [{ 
      "name": "OFFICE", 
      "channels": [{ 
       "name": "CHANNEL-001", 
       "currentVolume": 0, 
       "maxVolume": 0, 
       "yesterdayVolume": 0 
      }] 
     }] 
    }] 
}] 

此外,我有點不熟悉設置模型和商店。我認爲這是我失去了一些東西。我是否基於API響應正確構建模型?我試着閱讀文檔,但我仍然無法圍繞它進行包裝。

回答

0

錯誤500不是ExtJS問題。這是一個後端問題。您應該檢查您使用的後端技術並將其添加到標籤以獲得任何幫助。

檢查'接受'標題,它似乎是空的。我不知道我怎麼能有一個應用程序/ JSON有正確連接到它)

proxy: { 
    headers: { 
     Accept: 'application/json' 
    }, 
1

錯誤代碼500通知:

服務器遇到阻止它完成請求的意外情況。

正如我所看到的那樣,在Java端處理代碼時,您會得到NullPointerException。 因此,當發生意外的異常時,會在您的瀏覽器上顯示Http 500錯誤代碼。這個錯誤代碼在客戶端沒有什麼可做的。