01.html:1 Access to XMLHttpRequest at 'http://localhost:8001/eduservice/teacher/findAll' from origin 'http://127.0.0.1:8848' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这个问题很常见,只要前端页面的访问地址和后端的请求地址中三个因素不一致就会导致这个跨域问题.
三个因素:
1.访问协议 (比如:前端的是http, 后端是https)
2.IP地址
3.端口号
以上三个因素中有一个不一致就会导致跨域问题,解决方案有很多常用的有以下.
解决方案:
在后端的Controller中加上@Crossorgin注解就可以解决跨域问题了.