Skip to content

Instantly share code, notes, and snippets.

@kymtwyf
Last active October 26, 2015 11:30
Show Gist options
  • Save kymtwyf/c03449bc5b80597a41c2 to your computer and use it in GitHub Desktop.
Save kymtwyf/c03449bc5b80597a41c2 to your computer and use it in GitHub Desktop.
XMLHttpRequest cannot load http://XXX Origin http://XXX is not allowed by Access-Control-Allow-Origin.

参考

HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "这里写允许的头,比如Content-Type 等");
chain.doFilter(req, res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment