我试图使用一些跨域的Web服务。当我禁用chrome的web安全,它是工作正常。我希望它没有这样工作,所以我已经尝试添加cross-domain.xml和仍然没有工作。当我搜索更多,了解CORS启用在tomcat。
从 www.w3/wiki/CORS_Enabled
对于Apache Apache可以配置为使用mod_headers公开此标头。默认情况下,这是在Apache中启用的,但是您可能希望通过运行以下命令确保其在您的部署中已启用:
a2enmod headers要显示标题,您可以在,和, .htaccess文件。
< IfModule mod_headers.c> 标题集Access-Control-Allow-Origin*< / IfModule>
任何人都可以让我知道在哪里添加TOMCAT中的配置和确切的文件。我使用的是eclipse的tomcat。
感谢任何帮助。
解决方案Tomcat中的CORS支持通过过滤器提供。您需要将此过滤器添加到您的web.xml文件并配置它以满足您的要求。有关可用配置选项的完整详细信息,请参见 Tomcat文档。 / p>
I am trying to consume some web services which are cross domain. When I disable chrome's web-security it is working fine. I want it to work without this so I have tried adding cross-domain.xml and still it didnt work. When i searched more, came to know about CORS enabling in tomcat.
from www.w3/wiki/CORS_Enabled
For Apache Apache can be configured to expose this header using mod_headers. This is enabled by default in Apache, however you may want to ensure it's enabled in your deployment by running the following command:
a2enmod headersTo expose the header, you can add the following line inside , , and sections, or within an .htaccess file.
<IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule>
Can anyone please let me know where to add these configurations in TOMCAT and in which files exactly. I am using tomcat from eclipse.
Appreciate any help.
解决方案CORS support in Tomcat is provided via a filter. You need to add this filter to your web.xml file and configure it to match your requirements. Full details on the configuration options available can be found in the Tomcat Documentation.
更多推荐
如何在apache tomcat中启用CORS
发布评论