jsp页面报错XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access.
一种解决方式是在服务器端加这样一句代码:
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse().setHeader("Access-Control-Allow-Origin", "*");
还有一种方式是在前段页面加一行代码:
dataType: 'JSONP',