java后台接口SSM框架解决跨域问题

这几天和前端对接接口,前端的错误信息是:

 

 注释:
  Failed to load http://192.168.3.3:8080/Light_Push/webFrames.action?page=1&searchProject=1&page=1&searchProject=1: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin              'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

前端用了vue,axios(http客户端)
后端ssm框架,spring版本是3.2.13

发现可以从后台spring跨域着手解决

解决跨域方法:

第一步:导入jar包

  cors-filter-1.7.jar、java-property-utils-1.9.jar

  下载地址:http://pan.baidu.com/s/1pLkLPGJ

第二步:在web.xml文件配置


  CORS
  com.thetransactioncompany.cors.CORSFilter
  
   cors.allowOrigin  
   *
  

  
   cors.supportedMethods
    GET, POST, HEAD, PUT, DELETE
  

  
   cors.supportedHeaders
    Accept, Origin, X-Requested-With, Content-Type, Last-Modified
  

  
   cors.exposedHeaders
   Set-Cookie
  

  
   cors.supportsCredentials
   true
  

 

 
  CORS
  /*
 

转载于:https://www.cnblogs.com/Sailsail/p/7683939.html

你可能感兴趣的:(java后台接口SSM框架解决跨域问题)