通过修复web.xml来实现跨域
程序员文章站
2024-01-31 20:31:04
...
通过修复web.xml来实现跨域
(1)在开发项目中加入支持库,或把支持库直接丢到tomcat的lib目录下,下载地址:http://cdn.besdlab.cn/cors-lib.rar
(2)修改web.xml,增加以下代码
<filter> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> <init-param> <param-name>cors.allowOrigin</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.supportedMethods</param-name> <param-value>GET, POST, HEAD, PUT, DELETE</param-value> </init-param> <init-param> <param-name>cors.supportedHeaders</param-name> <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value> </init-param> <init-param> <param-name>cors.exposedHeaders</param-name> <param-value>Set-Cookie</param-value> </init-param> <init-param> <param-name>cors.supportsCredentials</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
上一篇: MySQL5.0中文问题的实际解决方案
下一篇: php中mysql执行有关问题