如何解决NO ‘Access-Control-Allow-Origin’ header is present on the requested resource

在使用axios进行前后端通信的时候,报出了跨域问题,详细看下面图片

如何解决NO ‘Access-Control-Allow-Origin’ header is present on the requested resource_第1张图片

解决方式如下:

在相应的接口控制类及方法上添加注解

@CrossOrigin

如何解决NO ‘Access-Control-Allow-Origin’ header is present on the requested resource_第2张图片

再进行测试时,直接获得了想要获取的数据

如何解决NO ‘Access-Control-Allow-Origin’ header is present on the requested resource_第3张图片

 

 

 

你可能感兴趣的:(如何解决NO ‘Access-Control-Allow-Origin’ header is present on the requested resource)