Home > Database > Mysql Tutorial > Java Web如何设置多个Access

Java Web如何设置多个Access

WBOY
Release: 2016-06-07 15:36:39
Original
1224 people have browsed it

有没有办法让 Access-Control-Allow-Origin header允许设置 multiple cross-domains呢? 如果设置 response.addHeader("Access-Control-Allow-Origin","*"); 感觉这个接口太开放了,不太安全。 我想只设置自己指定的若干个域名或者端口可以调用接口。 想下面

有没有办法让Access-Control-Allow-Origin header允许设置multiple cross-domains呢?

如果设置 

response.addHeader("Access-Control-Allow-Origin","*");
Copy after login
感觉这个接口太开放了,不太安全。 我想只设置自己指定的若干个域名或者端口可以调用接口。

想下面这样:

Access-Control-Allow-Origin: http://www.domain1.com, http://domain2.com
Copy after login

 现在我通过这个方式,在filter里面设置头信息。

response.addHeader("Access-Control-Allow-Origin","http://www.domain1.com:9000");
response.addHeader("Access-Control-Allow-Origin","http://www.domain2.com:8080");
Copy after login

但是浏览器报这个错误。

The 'Access-Control-Allow-Origin' header contains multiple values 'http://www.liuxuewei.com:9000, http://www.liuxuewei.com:8080', but only one is allowed. Origin 'http://www.liuxuewei.com:9000' is therefore not allowed access.
Copy after login

Java Web如何设置多个Access



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template