前端
jQuery方式
.ajax({
type: "POST",
url: "http://xxx.com/api/test",
dataType: 'jsonp',
xhrFields: {
withCredentials: true //支持跨域
},
success:function(data){
}
})
原生ajax
xhr.withCredentials = true;
后端
HttpServletResponse res;
res.setHeader("Access-Control-Allow-Origin", "*");