# cd /usr/local/Soft/tomcat/conf
# vim web.xml
将如下代码拷贝到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>
提示:粘贴完毕后,ESC ,按shift+: 输入wq 最后回车保存退出即可