通过设置http header方式允许跨域名请求
more details
browser(client) side code examples:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
server side code examples:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control
怎样配置Apache 服务器允许跨域名请求
How do we fix cross domain scripting issue ?
The simple solution is to allow the server to which request is being made to server request to any domain or to a list of domains. The important thing to remember is that the changes are to be made in the server which is serving the web service.
There are multiple ways to do it
Destoon B2B网站管理系统是一套完善的B2B(电子商务)行业门户解决方案。系统基于PHP+MySQL开发,采用B/S架构,模板与程序分离,源码开放。模型化的开发思路,可扩展或删除任何功能;创新的缓存技术与数据库设计,可负载千万级别数据容量及访问。 系统特性1、跨平台。支持Linux/Unix/Windows服务器,支持Apache/IIS/Zeus等2、跨浏览器。基于最新Web标准构建,在
1. You change settings in your apache’s httpd-vhosts.conf file ( I am using Apache 2.2 )
ServerAdmin webmaster@dummy-host.com DocumentRoot “C:/apache-tomcat-6.0.29/webapps/myApplication” ServerName skill-guru.com ErrorLog “logs/skg1-error.log” CustomLog “logs/skg1-access.log” common Header set Access-Control-Allow-Origin “*” Options -Indexes FollowSymLinks AllowOverride AuthConfig FileInfo Order allow,deny Allow from all JkUnmount /*.jsp ajp13
Now after you set the value in apache server and look at the header and would see
HTTP/1.1 200 OK
Date: Mon, 01 Dec 2008 00:23:53 GMT
Server: Apache/2.0.61
Access-Control-Allow-Origin: *
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/xml
怎样配置Tomcat 服务器允许跨域名请求
If you do not plan to use Apache and for some reasons using tomcat or any other similar web Container which supports filter, here is a ready made solution, Cors Filter
This gives you a servlet filter which is compatible with any Java Servlet 2.5+ web container.
Installation is very simple. Add the jar to your libraries
In you web.xml
add this line
CORS com.thetransactioncompany.cors.CORSFilter CORS /*









