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

Chrome's plugin CORS Toggle doesn't work using POST/PUT/DELETE 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方法。事实上,当我 运行 我的 anguarjs http 文件和当我尝试使用不同的方法(例如 PUT)时,Chrome 的控制台显示此错误:Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.。在我看来,该插件没有所有 CORS 许可。有人可以帮助我吗?

删除插件。尝试将此行添加到您的 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>