首先处理跨域问题
springboot 有处理跨域的注解@CrossOrigin
这样已经可以处理跨域请求,但session并不共享
注解修改如下:
@CrossOrigin(allowCredentials="true",allowedHeaders="*")
同时前端js ajax部分加入:
xhrFields:{
withCredentials:true
},
function ajaxtest(){
var url = "http://10.11.64.198:8888/t";
$.ajax({
url: url,
type: 'POST',
async:true,
xhrFields:{
withCredentials:true
},
success: function(respon){
},
error: function(){
alert('服务器发生错误!');
}
});
}
完成