后台设置:
response.setHeader("Access-Control-Allow-Credentials","true");
response.addHeader("Access-Control-Allow-Origin",request.getHeader("Origin"));
response.addHeader("Access-Control-Allow-Methods","POST");
response.addHeader("Access-Control-Allow-Headers","x-requested-with,content-type");
ajax写法
$.ajax({
type : "POST",
url : 'https://xxxx:18080/app/company/queryList?currentPage=1&pageSize=10',
dataType : "JSON",
data : "",
async: false,
xhrFields: {withCredentials: true}, success : function(data){ console.log("2="+ data.obj); } });