Access to XMLHttpRequest at ‘http://localhost:8088/upload‘ from origin ‘http://localhost:8080‘ has b

Access to XMLHttpRequest at 'http://localhost:8088/upload' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

前端访问后端链接这个错误,一般是跨域问题所导致的,在后端的接口上加入@CrossOrigin注解即可

@RestController
@CrossOrigin可以加在类上,也可以加到方法上
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/upload")
    public String uploadStudent(){
        return "ok";
    }
}

上一篇:javascript js字母大小写转换方法


下一篇:ES6 模糊查询(不区分大小写)