解决Tomcat下访问资源跨域,手机端预览资源跨域
- 修改tomcat下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> </filter> <filter-mapping> <filter-name>CorsFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>`
- lib下添加下面jar包
[https://download.csdn.net/download/IT_CcMan/86245358]备注:(免费下载,不需要积分) - 重启tomcat就可以访问了