0
我試圖使用Dojo工具包似乎呼叫encountring一些的所有主題,這是與道場調用調用REST Web服務道場JAX-RS調用問題
dojo.xhrGet({
url: 'http://localhost:9080/TestJMSWeb/jaxrs/categories/all',
handleAs: 'json',
timeout: 2000,
load: callback
});
var callback = dojo.hitch(this, function(data) {
var massagedData = {
label: 'categorie',
identifier: 'id',
items: data
}
this.store = new dojo.data.ItemFileReadStore({data: massagedData});
});
WebService的代碼是在這裏
@GET
@Path("/all")
@Produces("application/json")
public JSONArray getAllCategories() throws IOException {
final List<Categorie> allCategories = manager.getCategories();
if (allCategories == null || allCategories.isEmpty())
throw new WebApplicationException(ErrorUtil.jSONArrayResponse(Status.NO_CONTENT, "No category found"));
JSONArray jsonArray = jsonCustomerArray(allCategories);
return jsonArray;
}
當我打電話的web服務我得到一個錯誤信息
ResourceRegis I org.apache.wink.server.internal.registry.ResourceRegistry filterDispatchMethods The system cannot find any method in the ressources.CategorieRessouce class that supports OPTIONS. Verify that a method exists.
[4/24/12 1:23:41:531 GMT] 0000002f SystemErr R 0 TestJMSWeb INFO [WebContainer : 0] openjpa.Runtime - OpenJPA dynamically loaded a validation provider.
似乎試圖調用ŧ當我使用.xhrGet函數時,他使用OPTIONS方法重新分配了什麼問題?
測試解決方案 之前,我有一個麻煩,我不能出於安全原因,數據
的XMLHttpRequest無法加載的http://本地主機:9080/TestJMSWeb/JAXRS /分類/所有。 Access-Control-Allow-Origin不允許源http:// localhost:8080。 – 2012-04-24 18:24:18
所以你的數據在localhost:9080上,但你的dojo web應用程序在localhost:8080上?即使你看不到數據或訪問數據,這仍然不應該讓你在dojo/_base/xhr.js文件中註釋723-729行。還是你說你的網絡服務器需要Access-Control-Allow-Orgin頭文件? – MBillau 2012-04-24 20:30:34