1.進行ajax請求時加入
2.過濾器中設置請求頭
//跨域配置
response1.setHeader("Access-Control-Allow-Credentials","true");
response1.setHeader("Access-Control-Allow-Origin","http://192.168.1.114:8021");(注意:這里寫前端服務器地址糕再,如果不是這個服務器的請求肄扎,則會被過濾)
response1.setHeader("Access-Control-Allow-Headers","Content-Type,?Access-Control-Allow-Headers,?Authorization,?X-Requested-With");