0
我嘗試添加一些標題,以允許CORS後,它的工作相當不錯過,但這次它給我相同的代碼的Restlet 1001增加頭部
Form responseHeaders = addHeader((Form) getResponse().getAttributes().get("org.restlet.http.headers"));
if (responseHeaders != null){
getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
}
,所以這是一個Restlet1001連接錯誤調用添加標題方法的代碼中,添加標題的方法是:
public static Form addHeader(Form responseHeaders){
if (responseHeaders == null) {
responseHeaders = new Form();
responseHeaders.add("Access-Control-Allow-Origin", "*");
responseHeaders.add("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
responseHeaders.add("Access-Control-Allow-Headers", "authCode");
responseHeaders.add("Access-Control-Allow-Headers", "origin, x-requested-with, content-type");
return responseHeaders;
}
return null;
}
後相當長的一段嘗試&錯誤,谷歌,我仍然不知道爲什麼它給了我:
2013-07-07 19:39:24 127.0.0.1 - - 8015 GET /api/v1.0/users/findSession - 200 - 0 159 http://localhost:8015 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 -
2013-07-07 19:39:24 127.0.0.1 - - 8015 GET /api/v1.0/users/findSession - 1001 - 0 1 http://localhost:8015 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 -
2013-07-07 19:39:24 127.0.0.1 - - 8015 GET /api/v1.0/users/findSession - 1001 - 0 1 http://localhost:8015 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 -