前端ajax 参数配置:

$.ajax({
  crossDomain: true,   xhrFields: {    withCredentials: true   },   contentType: 'text/plain',
  async:true,
  success:function(dt){
  ...
  }
})

后端配置(java):

ajax 跨域请求 cors 配置

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

坑1:如遇到传递方式GET 或POST 被变为OPTION,则需要注意是否未配置

contentType: 'text/plain'

不能使用 contentType: "application/json"
如果后台不支持
text/plain,那么就为空,使用默认值(application/x-www-form-urlencoded; charset=UTF-8)



坑2:如不能传递ajax 跨域请求 cors 配置,需要注意是否已配置
 withCredentials
 

 




相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-09-08
  • 2021-09-21
  • 2021-10-15
相关资源
相似解决方案