httpsession跨域请求不能保存的问题

来源:互联网 发布:06款雅马哈r1数据 编辑:程序博客网 时间:2024/06/03 07:20

前端设置

$.ajaxSetup( {    xhrFields: {        withCredentials: true    }} );
修改跨域请求携带cookie


后端修改

String origin = request.getHeader("Origin");if(origin != null){   response.setHeader("Access-Control-Allow-Origin", origin);}else{   response.setHeader("Access-Control-Allow-Origin", "*");}response.setHeader("Access-Control-Allow-Credentials","true");
修改后端请求允许跨域携带cookie

转载文章

http://harttle.com/2016/12/28/cors-with-cookie.html#3

原创粉丝点击