简体   繁体   English

Chrome的插件CORS Toggle无法使用POST / PUT / DELETE方法工作

[英]Chrome's plugin CORS Toggle doesn't work using POST/PUT/DELETE method

I already solved the problem: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access 我已经解决了问题: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access , a problem of CORS, and I solved installing "CORS Toggle" Plugin of Chrome, but it works only for GET method. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access ,这是CORS的问题,我解决了安装Chrome的“ CORS Toggle”插件的问题,但仅适用于GET方法。 In fact, when I run my anguarjs http file and when I try to use a different method, such as PUT, Chrome's console show this error: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response. 实际上,当我运行anguarjs http文件并且尝试使用其他方法(例如PUT)时,Chrome的控制台会显示此错误: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response. . In my opinion, that plugin doesn't have all the CORS permits. 我认为该插件没有所有CORS许可。 Somebody can help me? 有人可以帮助我吗?

Remove the plugin. 删除插件。 Try to add this rows in your web.xml file: 尝试在您的web.xml文件中添加以下行:

<filter> <filter-name>CorsFilter</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> <init-param> <param-name>cors.allowed.origins</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowed.methods</param-name> <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value> </init-param> </filter> <filter-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM