最近在学后端用java写接口,
@RequestMapping(value = "/user", method = RequestMethod.GET) public List<User> getUser(){ return userService.findAll(); }
前台再自己调用接口,发现跨域
控制台错误是
Access to XMLHttpRequest at 'http://127.0.0.1:8080/user' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
但是用postman可以访问。。。
所以我不明白怎么解决 后端代码怎么写 如何一个完整的接口被成功调用