1 . 配置是在Control类上面加注解
@CrossOrigin @RestController
2.对应的js代码
/*不传参数的请求*/
function sendRequest(url,options){
$.ajax({
url:url,
type:"GET",
async: false, //同步
cache: false,
dataType:"json",
xhrFields: {
withCredentials: true(解决办法就是把true改成false)
},
success: function (response) {
options.success && options.success(response);
},
error: function () {
options.fail && options.fail();
}
});
}
3.IE浏览器调试报错:
信息如下
SEC7121: 将凭据标记设置为 true 时,不允许在 Access-Control-Allow-Origin 中使用通配符。