在java服务端解决跨域问题

但前端发送ajax跨域请求时,如果我们在服务端不做处理,请求会被浏览器禁止,抛出

No 'Access-Control-Allow-Origin' header is present on the requested resource错误,要解决它只需在服务端返回数据时增加允许跨域就行:

//允许跨域请求
response.addHeader("Access-Control-Allow-Origin", "*");


你可能感兴趣的:(跨域,Ajax)