Access to XMLHttpRequest at 'http://localhost:82/user/findUserById?id=3' from origin 'http://127.0.0 has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
当在进行前后端分离的时候,前端页面请求后台数据的数据,在浏览器出不来数据,且报以下错误时:
是因为前后端出现了跨越问题,子啊springboot的controller上添加一个注解便可解决该问题
@CrossOrigin
1、如果是需要添加全局跨域,就将注解添加在controller上
2、也可以指定某些方法跨域,