我在Windows Server 2012上运行Apache Tomcat。我所做的就是下载zip文件,在桌面上打开它,然后从那里开始/停止所有内容。
我试图从我的开发机器上运行的javascript程序访问服务器上运行的某些Web服务。我的开发机器和运行apache的服务器不在同一个网络上,我收到以下错误:
XMLHttpRequest cannot load service-call-snipped-for-brevity Response
to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the
requested resource. Origin 'http://localhost:8080' is
therefore not allowed access.
我已经读过我必须添加:
Header set Access-Control-Allow-Origin "*"
到httpd.conf文件,我在apache install conf dir中创建它(记得apache是"安装"通过我将下载的zip文件解压缩到我的桌面)并且如果它没有#t我可以创造它。
出色!
除非我完成所有操作并重新启动Apache Tomcat,否则我仍然会遇到同样的错误。
我错过了什么?
答案 0 :(得分:0)
Apache Tomcat不使用httpd.conf,Apache Webserver也是如此。
有很多答案可以告诉您如何为CORS配置Tomcat,例如How to enable CORS in apache tomcat