CORS跨域資源共享
跨域資源共享(CORS )是一種網絡浏覽器的技術規範,它為Web伺服器定義了一種方式,允許網頁從不同的域通路其資源。
Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
if (responseHeaders == null) {
responseHeaders = new Form();
getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
}
responseHeaders.add("Access-Control-Allow-Origin", "*");
responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS");
responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
responseHeaders.add("Access-Control-Allow-Credentials", "false");
responseHeaders.add("Access-Control-Max-Age", "60");
紅色是關鍵
在chrome firefox 等浏覽器可以,但是IE8不支援。
轉載于:https://www.cnblogs.com/tongdengquan/p/6090520.html